7
8

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.

Chromeでローカルのファイルを開いたらCORSポリシーエラー

Posted at

現象

chromeでローカルのファイルを開いたらこんなエラーが出た。

Access to XMLHttpRequest at '/file/to/something' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

原因

どうやら、chromeのセキュリティ設定のクロスサイトXX攻撃(スクリプトとかフォージュリとか)への対策で拒否されるらしい。

対策

chromeの起動オプションで一時的にセキュリティ設定をオフにできる。

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files --disable-web-security --user-data-dir --disable-features=CrossSiteDocumentBlockingIfIsolating
7
8
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
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?