0

I am trying to accomplish the following (if possible).

I have a single page application at localhost:8080 and everything currently lands on localhost:8080/ even if a user enters: localhost:8080/signIn

It does client side routing so that after you land on localhost:8080/ you can click a button and it takes you to localhost:8080/signIn

Is there a way using springboot to allow whatever the user passes in without having it redirect automatically to localhost:8080/ (all the while returning the single page - index.html)?

Thanks!

rotsner
  • 642
  • 3
  • 6
  • 23
  • So you need any request on your backend to be redirected to localhost:8080/ ? Always? You don't have any functionality in your spring boot application on other url's? – ibexit Oct 25 '18 at 19:23

1 Answers1

2

Try this way

@Controller
@RequestMapping("/")
public class AnythingController{

    @RequestMapping(value="**",method = RequestMethod.GET)
    public String getAnything(){
        // your code
    }
}
Dmitry
  • 121
  • 4
  • While this does capture all incoming requests. I think I have a setting somewhere which redirects everything to `/` so even if they land on `localhost:8080/signIn` it is returning my code in the RequestMapping but there is a 302 redirect to `/` as well which is not what I want. – rotsner Oct 26 '18 at 17:40
  • Figured it out. I had a spring security context and so when a user was not logged in it would 302 redirect to `/` instead of `signIn` Your code works perfectly. Thanks. – rotsner Oct 30 '18 at 19:31