Springboot 和 React 应用程序不重定向
我有一个带有 ForwardingController 的 Springboot 和 React 应用程序:
@Controller
public class ForwardingController {
@RequestMapping(value = {"", "/", "/{path:[^\\.]+}/**"})
public String index(Model model) {
return "forward:/index.html";
}
}
// The regex is Copy from another StackOverflow post
当我卷曲 http://localhost:8085/tool
时,我得到一个空响应。
在浏览器中,我看到“无法访问网站”页面。
当我卷曲 http://localhost:8085/tool/
时,我将被转发到索引页面。
如果我向某人发送以下任何链接,并且他们点击其中一个,他们也会登陆“无法访问网站”页面。
http://localhost:8085/tool
http://localhost:8085/tool/
http://localhost:8085/tool/dashboard
我需要更改什么才能解决此问题?
(该工具是托管的 - 我提供的链接用于本地调试)
我不认为这是客户端问题,但这是我的 React 路线:
<React.Fragment>
<BrowserRouter>
<Route path="/tool" render={(props) => <MainLayout {...props} />} />
<Redirect from="/" to="/tool/dashboard" />
</BrowserRouter>
</React.Fragment>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论