0

I have an angularJs application, which uses $routeProvider to handle internal routing. The back end uses Rest controllers within a Spring Boot application. The application is based on this: https://spring.io/guides/tutorials/spring-security-and-angular-js/

What I want to do is send an email with an embedded link similar to "http://localhost:8080/link/key1234". The user should be able to click this, and go to specific content as indicated by the key1234 variable.

I have seen a similar item (Refreshing page gives "Page not found") which suggests using .htaccess to handle this, but I do not currently have a .htaccess file.

I also have html5mode on [$locationProvider.html5Mode(true);]

Another suggestion (Spring Boot with AngularJS html5Mode) is to intercept the request and redirect to the home page. Whilst this prevents the application from failing, I need the user to go to a specific page, not the Home page.

I have managed to get quite confused about the interactions of my different components. Can you point me in the right direction to enable a specific link to be provided ?

UPDATE

I think that the .htaccess file is a red herring.

The spring.io tutorial includes the following code:

@RequestMapping(value = "/{[path:[^\\.]*}")
public String redirect() {
  return "forward:/";
}

And this segment performs a redirect for some of the pages.

However, my tests (until recently) had been using "http://localhost:8080/public/about" which is not getting picked up by the RequestMapping snippet above.

If I use a single level url (e.g. "http://localhost:8080/test") then my existing code works fine.

It looks like there is a flaw in this regex.

Community
  • 1
  • 1
MarkA
  • 1,132
  • 1
  • 11
  • 21
  • Is your client running in the same Spring Boot application, or you are using a different server, like "grunt serve"? – Sanjay Aug 07 '15 at 10:54
  • Why I asked it because, whatever server your client is running on, whether on the same application or "grunt serve," you would need to find the equivalent of .htaccess. – Sanjay Aug 07 '15 at 11:20
  • Thank you Sanjay. At the moment, my client is running through Spring Boot. – MarkA Aug 07 '15 at 12:56

1 Answers1

1

When a request like http://localhost:8080/link/key1234 hits your server, you would need to forward the request to home page. Then, the client should get the response of the home page, while the URL will still be http://localhost:8080/link/key1234. html5mode will then come to play, changing the view at the client side.

I think the best way to do it might be to use urlrewrite filter, which should forward all requests except those starting with, say /api/**, to the home page.

Community
  • 1
  • 1
Sanjay
  • 8,755
  • 7
  • 46
  • 62