我创建了 Angular JS 项目,该项目在端口 4200 下的节点服务器中运行,并且基于 Spring boot 的 REST 数据服务作为单独的项目在 eclipse 中的 8080 端口下运行。 REST 服务 (RS) 部分使用基于 OAuth 的安全性并验证每个 access_token 请求。作为单独的实体,这工作得非常好。
现在,我尝试在 WAR 的根文件夹中构建带有角度编译输出的单个 WAR,并且如果我访问应用程序(通过访问任何 URL) - 在 Angular NG 路由器 Spring boot 安全性出现并拒绝无 OAuth 验证的请求之前。
@Override
public void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**").authorizeRequests().antMatchers("/error").permitAll().anyRequest().authenticated();
http.csrf().disable();
http.headers().frameOptions().disable();
http.cors().configurationSource(new CorsConfigurationSource() {
@Override
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedHeaders(Collections.singletonList("*"));
config.setAllowedMethods(Collections.singletonList("*"));
config.addAllowedOrigin("*");
config.setAllowCredentials(true);
return config;
}
});
}
这是我的安全配置文件。请告知将两个单独的 WAR 放入单个模块 EAR 中是否可以解决此问题。
最佳答案
有一个项目结构可以生成一场 war 。
编辑: 也许您需要创建一个 proxy.conf.json 文件
{
"/api/*": {
"target": "http://localhost:8080",
"secure": false
}
}
并将其添加到architect-serve-options-proxyConfig 中的 angular.json 文件中
关于java - Spring Boot + Angular JS JBoss 部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57360062/