报错 When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" ....

错误:

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.

翻译过来就是:
当 allowCredentials 为 true 时,allowedOrigins 不能包含特殊值“*”,因为不能在“访问控制-允许-源”响应标头上设置该值。要允许一组源的凭据,请显式列出它们或考虑改用“allowedOriginPatterns”。

解决措施

上面错误信息都已经告诉你了,把 allowedOrigins 替换成 allowedOriginPatterns。

效果图
image

posted @ 2022-08-13 11:40  小洋ssr  阅读(2538)  评论(1编辑  收藏  举报