When allowCredentials is true, allowedOrigins cannot contain the special value “*“
2021-09-06 22:22
1591 查看
前言
- 项目接口访问出现
allowedOrigins cannot contain the special value "*"
java.lang.IllegalArgumentException: When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
修改方式
- 修改
allowedOrigins
为allowedOriginPatterns
- 修改前
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") .allowCredentials(true) .maxAge(3600) .allowedHeaders("*"); }
- 修改后
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOriginPatterns("*") .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") .allowCredentials(true) .maxAge(3600) .allowedHeaders("*"); }
相关文章推荐
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正
- Attribute value request.getParameter("digyso") is quoted with " which must be escaped when used within the value
- Attribute value is quoted with " which must be escaped when used within the value 问题解决
- XMLHttpRequest cannot load – Origin is not allowed by Access-Control-Allow-Origin.
- PostBack the form when a value is selected from the results returned by autocomplete extender
- Cannot modify the return value of 'System...ClientRectangle' because it is not a variable
- 错误:is quoted with " which must be escaped when used within the value .
- WP7“Navigation is not allowed when the task is not in the foreground.”解决方案
- WP7“Navigation is not allowed when the task is not in the foreground.”解决方案
- the 'access-control-allow-origin' header has a value 'http://localhost' but origin is null
- JasperException: is quoted with " which must be escaped when used within the value
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正1
- 错误:is quoted with " which must be escaped when used within the value (转载)
- JasperException: is quoted with " which must be escaped when used within the value
- 跨域:The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed
- Attribute value ("XXX") is quoted with " which must be escaped when used within the value 异常的修正2
- Packet for query is too large (1986748 > 1048576). You can change this value on the server by setting the max_allowed_pa
- JasperException: is quoted with " which must be escaped when used within the value
- 子页面关闭时传值给父页面(pass value from child window to parent window, when the child window is closing)
- ValueError: Object arrays cannot be loaded when allow_pickle=False