【发布时间】:2020-03-20 09:33:29
【问题描述】:
从小上下文开始这个问题,我做了前端与 springboot 中的后端实现反应。
在我开发时,我在 package.json 中设置了"proxy": "http://localhost:8080/",,以便它可以将我的请求代理到 localhost:8080,它是 spring 的 tomcat 服务器。
对于生产,我使用 frontend-maven-plugin 构建 react 应用程序和 maven-antrun-plugin 将 react 生产构建复制到后端目录(target/classes/public),最后部署到 heroku。
在我的项目中添加 Spring Security 后,我意识到它增加了对“/login”上登录页面的支持,我通过更改 http.loginPage() 将其更改为“/my-login”
@Override
protected void configure(HttpSecurity http) throws Exception{
http.authorizeRequests()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/my-login")
.permitAll(true)
.and()
.logout()
.logoutSuccessUrl("/my-login?logout")
.permitAll();
http.cors();
现在的问题是我的登录页面在 react app 目录中,我不能在 spring boot 目录中有另一个登录页面。 我尝试使用 .jsp 登录页面作为中间体,该页面将与 Spring Security 对话并从 react 方对其发出发布请求,但实际上无法用这种方法做任何事情。
那么有没有其他方法可以让 react 提供登录页面,仍然可以与 spring security 交互?
谢谢,
帕拉斯
【问题讨论】:
-
你有没有想过这个问题?我遇到了同样的问题。 SpringBoot 后端与 Spring Security 和 React 前端
标签: java reactjs spring spring-boot spring-security