1. 程式人生 > >VUE:-Error- vue開發模式正常,部署後提示fetch跨域

VUE:-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不再同一個域。