StackShelf
HTTPエラー エラー解決

has been blocked by CORS policy: Request header field authorization is not allowed の原因と解決法

has been blocked by CORS policy: Request header field authorization is not allowed の原因と具体的な解決手順をまとめました。

1分で読める
httpHTTPエラーhas been blocked by CORS policyCORShas been blocked by CORS policy: Request

エラーメッセージ(全文)

has been blocked by CORS policy: Request header field authorization is not allowed

このエラーとは

has been blocked by CORS policy: Request header field authorization is not allowed は HTTP 開発でよく遭遇するエラーです。

想定環境: Windows / macOS / Linux

よく出る状況: ブラウザ fetch / axios 時

よくある原因

  • サーバー側 CORS 未設定
  • preflight OPTIONS 未対応
  • credentials 設定不一致

解決方法

方法1: サーバーで CORS ヘッダ

Access-Control-Allow-Origin を設定.

それでも直らないとき

バージョン情報(HTTP のバージョン、OS、実行コマンド)を添えて、エラーメッセージ全文と直前に変更した点を確認してください。ログの数行上にも原因の手がかりが残っていることが多いです。

まとめ

「has been blocked by CORS policy: Request header field authorization is not allowed」は サーバー側 CORS 未設定 が原因のことが多いです。上記の手順で切り分けてください。

次にやること

同じ HTTP カテゴリの関連エラーもあわせて確認してください。

よくある質問

has been blocked by CORS policy: Request header field authorization is not al… とは何ですか?

has been blocked by CORS policy: Request header field authorization is not allowed は HTTP 実行時に表示されるエラーです。サーバー側 CORS 未設定

has been blocked by CORS policy: Request header field authorization is not al… の原因は?

サーバー側 CORS 未設定。preflight OPTIONS 未対応。credentials 設定不一致。

has been blocked by CORS policy: Request header field authorization is not al… の直し方は?

サーバーで CORS ヘッダ:Access-Control-Allow-Origin を設定.

HTTP で has been blocked by CORS policy が出るのはなぜ?

ブラウザ fetch / axios 時

has been blocked by CORS policy: Request header field authorization is not al… を防ぐには?

次に読むべき記事

同カテゴリ「HTTPエラー」の記事

学習ルート

体系的に学びたい方はこちらから。

エラー・トラブル集で続きを探す →

あわせて読みたい