I need the following:
Any request to
- https://localhost:8443
- https://localhost:8443/
- https://localhost:8443/test
- https://localhost:8443/api
and so on, should be forwarded to
https://localhost:8443/a/web/index.html
Now, this is how I managed to do that:
@Controller
public class ForwardController {
@RequestMapping(value = "/*", method = RequestMethod.GET)
public String redirectRoot(HttpServletRequest request) {
return "forward:/a/web/index.html";
}
}
The problem is:
This also matches https://localhost:8443/api/ (note the / at the end).
This is a problem because that's where I want the Spring Data REST base path to be:
spring.data.rest.base-path=/api/
/api != /api/
when it comes to REST endpoints.
What should work but somehow doesn't
I have tried several different regular expressions but I am still not able to accomplish what I want. For example (demo):
@RequestMapping(value = "/[^/]+", method = RequestMethod.GET)
Will now work for Spring Data - I'm getting all the resource information I expect, but accessing https://localhost:8443/ is now broken and the web-client cannot be reached anymore.
The same goes for
@RequestMapping(value = "/{path}", method = RequestMethod.GET)
@RequestMapping(value = "/{path:[^/]+}", method = RequestMethod.GET)
which behave like /*
(also matches the next /
).
This issue is already haunting me for weeks and still no solution insight.
This whole question can also be seen as:
Why is "/[^/]+"
not matching https://localhost:8443/whatever ?