aliyun / alibabacloud-alfa

阿里云微前端解决方案
https://aliyun.github.io/alibabacloud-alfa
MIT License
846 stars 83 forks source link

打正式包 需要Access-Control-Allow-Origin #62

Closed longkehuawei closed 3 years ago

longkehuawei commented 3 years ago

'http://localhost:6065/urule/res/urule-asserts/js/os-example.manifest.json' from origin 'http://localhost:8081' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Boelroy commented 3 years ago

可以设置 webpack 的跨域:

{
  devServer: {
    headers: {
      'Access-Control-Allow-Origin': '*',
    }
  }
}
longkehuawei commented 3 years ago

正式打包怎么办呀

longkehuawei commented 3 years ago

devtool: 'source-map', devServer: { port: '6065', clientLogLevel: 'warning', disableHostCheck: true, compress: true, headers: { 'Access-Control-Allow-Origin': '*', }, overlay: { warnings: false, errors: true }, }, mode: 'development',

longkehuawei commented 3 years ago

这个是开发环境配置才有用吧,正式打包要怎么弄呢

Boelroy commented 3 years ago

这个是开发环境配置才有用吧,正式打包要怎么弄呢

正式环境如果部署在 CDN 上都是可以跨域请求的,如果是和后端代码部署在一起的,可以让后端针对静态文件都设置一下跨域头。