如何将OAuth2将URI从ViewControllerRegistry中排除,因为它在该路径上没有 /API
我有Spring Boot(后端)应用程序与React(Frontend)结合使用,因此两者都被包装为一个战争文件并部署到Tomcat Apache中,以使React路由从Spring Boot中进行工作,我必须在Spring Boot中添加配置,并且可以正常工作。下面是我添加的配置。所有包含API字符串的路径都有望按Spring Boot服务,并且也有效。
@Configuration
public class WebRouteConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
// Map "/"
registry.addViewController("/")
.setViewName("forward:/index.html");
// Single directory level - no need to exclude "api"
registry.addViewController("/{x:[\\w\\-]+}")
.setViewName("forward:/index.html");
registry.addViewController("/{x:^(?!api$).*$}/{y:[\\w\\-]+}")
.setViewName("forward:/index.html");
// Multi-level directory path, need to exclude "api" on the first part of the path
registry.addViewController("/{x:^(?!api$).*$}/ABC/{y:[\\w\\-]+}")
.setViewName("forward:/index.html");
}
但是我想在此处排除Oauth重定向URI(PATH = OAUTH/REDIRECT),因为它没有“ API”字符串,因此它正在重定向到没有为该路径配置的路由的前端。春季启动预计将接收OAuth/重定向页面,而无需路由反应路由,可以帮助我如何从注册表中排除此特定路径的注册表。
I have spring boot (backend) application combined with React(Frontend), So both are packaged as one war file and deployed into tomcat apache, In order to make react routing work from Spring boot I had to add configuration in spring boot and it works. Below is the configuration I added.All the paths that includes api strings are expected to serve by spring boot and that is working as well.
@Configuration
public class WebRouteConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
// Map "/"
registry.addViewController("/")
.setViewName("forward:/index.html");
// Single directory level - no need to exclude "api"
registry.addViewController("/{x:[\\w\\-]+}")
.setViewName("forward:/index.html");
registry.addViewController("/{x:^(?!api$).*$}/{y:[\\w\\-]+}")
.setViewName("forward:/index.html");
// Multi-level directory path, need to exclude "api" on the first part of the path
registry.addViewController("/{x:^(?!api$).*$}/ABC/{y:[\\w\\-]+}")
.setViewName("forward:/index.html");
}
But I wanted to exclude oauth redirect URI(path=oauth/redirect) here , As it does not have "api" string in that so it's being redirected to frontend where it does not have routing configured for that path. Spring boot is expected to receive oauth/redirect page without routing to react routing, could some body please help me how to exclude from the registry for this particular path.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论