第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:8082, http://localhost:8082', but only one is allowed.

The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:8082, http://localhost:8082', but only one is allowed.

http://img1.sycdn.imooc.com//5e7a180c0001764c10750960.jpg

http://img1.sycdn.imooc.com/5e7a14350001e0b810750960.jpg

可否在NGINX里,預(yù)先判斷是否包含與$http_origin相同信息,如果有,則不添加。

使用服務(wù)器測(cè)試頁(yè),訪問(wèn)正常。http://test.hisouth.cn/websocket02/?,請(qǐng)求頭信息正常。

使用本地測(cè)試頁(yè),http://localhost:8082/,連接服務(wù)器WebSocket,就會(huì)出現(xiàn)多請(qǐng)求origin。


static.zip

我找不到,在哪添加了兩次(這里面使用的sockjs)。

請(qǐng)問(wèn),如果NGINX配置了跨域,而前端又添加,允許跨域請(qǐng)求頭,是否會(huì)出現(xiàn)這樣的重復(fù)問(wèn)題。


http&http跨域

http://img1.sycdn.imooc.com//5e7a17920001e7d910750960.jpg

另外,請(qǐng)問(wèn)websocket連接中,是否不允許重定向操作。

正在回答

1 回答

不報(bào)錯(cuò):

Access-Control-Allow-Origin:*,?https://demo.hisouth.cn

報(bào)錯(cuò):

Access-Control-Allow-Origin:*,?https://demo.hisouth.cn,?https://demo.hisouth.cn

我目前處理:

# 在options中,添加一次跨域請(qǐng)求

# https://www.cnblogs.com/sunmmi/articles/5956554.html

if ($request_method = 'OPTIONS') {

add_header 'Access-Control-Allow-Origin' $http_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' 86400;

add_header 'Content-Type' 'text/plain charset=UTF-8';

add_header 'Content-Length' 0;

return 204;

}

# 最后判斷再匹配一次

# nginx 正則表達(dá)式

# https://www.cnblogs.com/bethal/p/5514557.html

if ($http_origin !~* '^http'){

add_header 'Access-Control-Allow-Origin' $http_origin;

}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:8082, http://localhost:8082', but only one is allowed.

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)