springboot because its MIME type (‘application/json‘) is not a supported stylesheet MIME type
问题说明前端项目基础架构是react,后端基础架构是springboot。前端的部署方式,通过maven打包成jar包,后端通过maven进行依赖,用户在浏览器访问127.0.0.1:8080端口来访问前端页面。也就是说前端所有的资源都是通过后端接口返回的。包括一些ccs、js、svg静态资源等等。当项目增加了资源认证服务Security+OATH2之后,需要对前端的一些资源进行过滤,否则在浏览器
·
问题说明
前端项目基础架构是react,后端基础架构是springboot。前端的部署方式,通过maven打包成jar包,后端通过maven进行依赖,用户在浏览器访问127.0.0.1:8080端口来访问前端页面。也就是说前端所有的资源都是通过后端接口返回的。包括一些ccs、js、svg静态资源等等。
当项目增加了资源认证服务Security+OATH2之后,需要对前端的一些资源进行过滤,否则在浏览器的控制台就会出现错误:because its MIME type (‘application/json’) is not a supported stylesheet MIME type
问题处理
如果跟我一样,项目中用的是Security+OATH2,在资源配置服务器中增加你要过滤的规则即可。
@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
@Autowired
private AuthLogoutSuccessHandler authLogoutSuccessHandler;
@Autowired
TokenStore tokenStore;
@Override
public void configure(HttpSecurity http) throws Exception {
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry =
http.exceptionHandling()
.and()
.logout()
.logoutUrl(cdpAuthConfig.getLogoutPath())
.logoutSuccessHandler(authLogoutSuccessHandler)
.and()
.authorizeRequests()
.antMatchers("/*.svg","/*.png","/*.js","/*.css").permitAll() // 在这里添加
.antMatchers("/**").authenticated();
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)