2017-09-10 5 views
0

$httpコールでwithCredentials: trueを使用していましたが、要求ヘッダーでセッションIDを送信しました。

しかし、私は直面していた:

"the value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'null' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."

をだから私はにサーバー側で私のCORSフィルターを変更:

response.setHeader("Access-Control-Allow-Origin", "http://localhost:8080/"); 

今、私はこのエラーを取得しています:

"The 'Access-Control-Allow-Origin' header has a value ' http://localhost:8080 ' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access."

ことができます誰も解決策を教えてください?

+0

元のリクエストヘッダーの値をAccess-Control-Allow-Originに戻すことができます。 'response.setHeader(" Access-Control-Allow-Origin "、request.getHeader(" Origin ")); ' – sideshowbarker

答えて

2

はこのスニペットを使用してみてください:

response.setHeader( "アクセス制御 - 許可 - 起源"、 "*");

+0

問題の説明で述べたように、 response.setHeader(" Access-Control-Allow-Origin "、" * ");リクエストの資格情報モードが 'インクルード'の場合、レスポンスの 'Access-Control-Allow-Origin'ヘッダーの値はワイルドカード '*'であってはなりません。 XMLHttpRequestによって開始された要求の信任状モードは、withCredentials属性によって制御されます。エラー。 –

関連する問題