ccess to XMLHttpRequest at http1270017070ueditorjspcontrolleraction=uploadimage from origin httplocalhost8090 has been blocked by CORS policy No Access-Control-Allow-Origin header is present on the re
可以通过在Nginx中设置反向代理来解决跨域问题。具体操作如下:
- 在Nginx的配置文件中添加以下代码:
location /ueditor {
proxy_pass http://127.0.0.1:7070;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
- 重启Nginx服务,使配置文件生效。
这样,当浏览器发送请求到http://localhost:8090/ueditor时,Nginx会将请求转发到http://127.0.0.1:7070/ueditor,并将请求头中的Host和X-Real-IP传递给后端服务器。由于请求是从同一域名下发起的,因此不会出现跨域问题。
原文地址: https://www.cveoy.top/t/topic/eNbz 著作权归作者所有。请勿转载和采集!