LoginSignup
10
10

More than 5 years have passed since last update.

【Mac】Google Chromeでローカルファイル参照時のエラー回避

Last updated at Posted at 2013-12-07

Google ChromeでJSONなどのローカルなデータを読み込もうとするとエラーが表示されます。

Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 

ターミナル.appから以下のようにchromeを起動すると良いです。

open -a /Applications/Google\ Chrome.app --args -allow-file-access-from-files index.html

今後起動しやすいように.bash_profileに以下の記述をしました。

alias google_chrome_dev="open -a /Applications/Google\ Chrome.app --args -allow-file-access-from-files"

これで、$ google_chrome_devと起動するとエラーが出ない状態のChromeが立ち上がります。
JSONを用いたアプリケーションの開発等で役にたつことでしょう。

10
10
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
10
10