简体   繁体   English

webpack构建react项目,资源文件CORS

[英]webpack build react project, the resource files CORS

I use webpack to build the react project, separate the font and images and other media files. 我使用webpack构建react项目,分离字体和图像以及其他媒体文件。 When the html show, the main.js will get the resource automatically. 当html显示时,main.js将自动获取资源。 The SPA html and js files are on different domains, then the browser show 'Access-Control-Allow-Origin' error message. SPA html和js文件位于不同的域,然后浏览器显示“ Access-Control-Allow-Origin”错误消息。 How should I do to resolve it? 我应该如何解决?

You can tweak the HTTP header on your origin server. 您可以在源服务器上调整HTTP标头。 All it takes is an additional HTTP header called Access-Control-Allow-Origin which allow CORS. 它所需要的只是一个附加的HTTP标头,称为Access-Control-Allow-Origin,它允许CORS。

A useful resource to get started: 一个有用的入门资源:

https://enable-cors.org/ https://enable-cors.org/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM