0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nginx のaccess-control-allow-origin-response-headerは 3種類のうちいずれかを単一で指定する必要がある

Last updated at Posted at 2019-07-17

3種類を併用する事は出来ず、3種類のうちいずれかを単一で指定する必要があるみたいです。
ここに書いてました。
https://www.w3.org/TR/cors/#access-control-allow-origin-response-header

The Access-Control-Allow-Origin header indicates whether a resource can be shared based by 
returning the value of the Origin request header, "*", or "null" in the response. ABNF:

Access-Control-Allow-Origin = "Access-Control-Allow-Origin" ":" origin-list-or-null | "*"
In practice the origin-list-or-null production is more constrained. 
Rather than allowing a space-separated list 
of origins, it is either a single origin or the string "null".

特定のOriginから

add_header Access-Control-Allow-Origin "http://hogehoge.jp"

全て許可

add_header Access-Control-Allow-Origin "*"

ローカルからのリクエスト

add_header Access-Control-Allow-Origin "null"

そりゃ、そうですよね。。。
ちなみに、アプリケーションから渡された、Access-Control-Allow-Originを適用させたい場合は
add_header 自体を指定しないが正解でした。てっきりnullを指定するものとばかり。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?