国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

Nginx跨域設置Access-Control-Allow-Origin無效的解決辦法

2024-08-30 12:24:37
字體:
來源:轉載
供稿:網友

nginx 版本 1.11.3

使用大家說的以下配置,驗證無效,跨域問題仍然存在

add_header 'Access-Control-Allow-Origin' '*';add_header 'Access-Control-Allow-Credentials' 'true';add_header 'Access-Control-Allow-Methods' 'GET,POST';

使用以下配置,生效。

if ($request_method = 'OPTIONS') {        add_header 'Access-Control-Allow-Origin' '*';        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';        add_header 'Access-Control-Max-Age' 1728000;        add_header 'Content-Type' 'text/plain charset=UTF-8';        add_header 'Content-Length' 0;        return 204;       }       if ($request_method = 'POST') {        add_header 'Access-Control-Allow-Origin' '*';        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';       }       if ($request_method = 'GET') {        add_header 'Access-Control-Allow-Origin' '*';        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';       }

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對錯新站長站的支持。如果你想了解更多相關內容請查看下面相關鏈接

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宁都县| 扬中市| 琼结县| 渝北区| 剑川县| 曲靖市| 玉龙| 云安县| 景谷| 石首市| 天峻县| 靖宇县| 土默特右旗| 新田县| 灵丘县| 资中县| 陇南市| 锡林郭勒盟| 大石桥市| 原阳县| 北辰区| 西吉县| 廊坊市| 山东省| 聊城市| 汕尾市| 剑河县| 车致| 卓资县| 固始县| 神农架林区| 昌宁县| 陇西县| 巴青县| 临夏县| 高淳县| 梓潼县| 东光县| 平湖市| 崇礼县| 垦利县|