【发布时间】:2019-06-25 17:05:08
【问题描述】:
在 Angular 应用程序中,我以这种方式拥有 proxy.conf.json
{
"/api/*": {
"target": "http://10.127.152.161:8080",
"secure": true,
"changeOrigin": true
},
"/rest/*": {
"target": "http://10.127.152.161:8080",
"secure": true,
"changeOrigin": true
},
"/auth/*": {
"target": "http://10.127.152.161:8080",
"secure": true,
"changeOrigin": true
}
}
由于在开发模式下,Angular 应用程序在 localhost:4200 上运行,将目标设置为 ipv4 地址:8080 会导致 CORS 标头问题。由于某些原因,我必须使用 http://10.127.152.161:8080 不是 localhost:8080 或 3000 端口。我添加了 add_header 'Access-Control-Allow-Origin' '*'; nginx conf 文件,但没有运气。如何解决这个问题?
【问题讨论】: