我的nginx后面有两个子域:panel.example.ir和API.example.ir当我从我的panelpanel.example. ir调用API.example.ir时,我看到一个错误:
Access to XMLHttpRequest at 'https://api.example.ir/api/test/pre_sale_customer_project_view?offset=0&limit=5&order=created_at.desc' from origin 'https://panel.example.ir' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
另外,当我将add_header Access-Control-Allow-Origin *;
添加到我的APInginx conf时,我有另一个错误如下!
Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values 'panel.example.ir, *', but only one is allowed.
我现在能做什么?
1条答案
按热度按时间ivqmmu1c1#
也许看看这篇文章。对于
add_header
,当你将它用作代理时,你将堆叠头值。在这篇文章中,它描述了如何隐藏原始的头文件,以便用nginx中的给定头文件替换它。How to overwrite http Content-Disposition header in nginx.conf location block?
所以在你的情况下,也许用途:
或者配置应用程序,使其始终使用正确的标头进行响应。