'Springboot and React application not redirecting
I have a Springboot and React app with a ForwardingController:
@Controller
public class ForwardingController {
@RequestMapping(value = {"", "/", "/{path:[^\\.]+}/**"})
public String index(Model model) {
return "forward:/index.html";
}
}
// The regex is copied from another StackOverflow post
When I curl http://localhost:8085/tool I get an empty response.
In the browser I get a "site cannot be reached" page.
When I curl http://localhost:8085/tool/ I am forwarded to the index page.
If I send someone any of the following links and they click on one, they also land on a "site cannot be reached" page.
http://localhost:8085/tool
http://localhost:8085/tool/
http://localhost:8085/tool/dashboard
What do I need to change to resolve this?
(The tool is hosted - the links I provided are for debugging locally)
I don't think this is a client-side issue but here is my React route:
<React.Fragment>
<BrowserRouter>
<Route path="/tool" render={(props) => <MainLayout {...props} />} />
<Redirect from="/" to="/tool/dashboard" />
</BrowserRouter>
</React.Fragment>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
