-Error- vue开发模式正常,部署后提示fetch跨域

vue开发fetch正常,部署后报错如下

Failed to load http://guozhaoip.com/good/front/classList: Response to
preflight request doesn’t pass access control check: No
‘Access-Control-Allow-Origin’ header is present on the requested
resource. Origin ‘http://www.guozhaoip.com’ is therefore not allowed
access. If an opaque response serves your needs, set the request’s
mode to ‘no-cors’ to fetch the resource with CORS disabled.

解决办法

  • 将env.js中
  • baseUrl = '//guozhaoip.com';
  • 改为
  • baseUrl = '//www.guozhaoip.com';
  • 原因为guozhaoip.com 与 www.guozhaoip.com不再同一个域。

猜你喜欢

转载自blog.csdn.net/u011374582/article/details/82862760