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?

CORS・ドメイン・オリジンまとめ Web開発でよく出てくる CORS(Cross-Origin Resource Sharing)、ドメイン、オリジン について整理します。

Posted at

ドメインとは
ドメインは、簡単に言うと「インターネット上の住所」のことです。
例:
https://example.com:8080/path/to/resource

example.com がドメイン
ポート番号(ここでは8080)も含めて扱う場合があります
2. オリジンとは
オリジンは、プロトコル + ドメイン + ポート を組み合わせたもので、セキュリティ上の境界として重要です。

CORS(Cross-Origin Resource Sharing)とは
ブラウザの 同一オリジンポリシー により、異なるオリジン間でのリソースのやり取りは制限されています。
CORSは、サーバーが特定のオリジンからのアクセスを許可する仕組み です。
3-1. 同一オリジンポリシーの例
許可される:https://example.com/page1.jshttps://example.com/api/data
許可されない:https://example.com/page1.jshttps://api.example.com/data
※サブドメインが違うだけでも別オリジン扱いになります。
3-2. CORSの基本的な仕組み
サーバー側で HTTP ヘッダーを付与することで、ブラウザに「このオリジンからのアクセスを許可するよ」と伝えます。

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?