【解决】When allowCredentials is true, allowedOrigins cannot contain the special value “*“ since
·
详细报错信息:
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.
at org.springframework.web.cors.CorsConfiguration.validateAllowCredentials(CorsConfiguration.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
前后台报错信息如图所示:
造成问题的原因及解决方案:
当allowCredentials为true时,allowedOrigins不能包含特殊值"*",因为它不能在"Access-Control-Allow-Origin"响应头中设置。 要允许凭证指向一组起源,可以显式地列出它们,或者考虑使用“allowedOriginPatterns”代替。
Thanks
更多推荐
已为社区贡献5条内容
所有评论(0)