Code

2014年3月6日木曜日

Chrome の Same Origin Policy を無効にする

Windows の場合を補足しておこう:
C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe --disable-web-security
# つまり、chrome.exe の後ろに --disable-web-security を追加する。またはショットカットを作って、パラメターとしてそれを渡す。

ただし、通常の chrome を実行している間、同じプログラムで二つプロセスが実行できないため、エラーが出ます。
こういうとき、下記のコマンドを実行しよう。
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
これで、違う chrome プロセスが実行されますので、安全モードの Chrome と web security 無効の Chrome が同時に実行できます。

Mac で一番いい方法見つけたので、メモしておこう。
.profile に下記を追加して、コマンドラインで chromex を実行すれば、 別ドメインへの XHR が実行できるようになる。

chrome () {
  /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $* 2>&1 &
}

alias chromex="chrome --disable-web-security"

 Safari の iOS web inspector はちょっと使いにくい。。。
 Mobile での HTML5 widget 開発には役立つだろう。:)

 それでは。

0 件のコメント:

コメントを投稿