【问题标题】:CorsRegistry configuration seems to have no effect in springCorsRegistry 配置在 spring 中似乎没有效果
【发布时间】:2017-02-11 19:01:37
【问题描述】:

addCorsMappings 功能在春季对我不起作用。 我刚刚:

public void addCorsMapping(CorsRegistry registry){ 
    registry.addMapping("/**").allowedOrigins("/**"); 
}

这是在我的 ServletConfig.java 中声明的。

客户端的错误是:

XMLHttpRequest cannot load http://localhost:8080/oauth/authorize?response_type=code&client_id=backoffice&state=xyz&redirect_uri=http://localhost:8080. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.". 

谁能告诉我为什么以及如何调试这个?

【问题讨论】:

    标签: spring spring-boot cors spring-security-oauth2


    【解决方案1】:

    应该是:

    public void addCorsMappings(CorsRegistry registry){ 
        registry.addMapping("/**").allowedOrigins("*"); 
    }
    

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-12
      • 2018-05-18
      • 1970-01-01
      相关资源
      最近更新 更多