簡體   English   中英

嘗試停用Chrome同源策略

[英]Trying to disable Chrome same origin policy

我正在嘗試遵循melonJS教程。 它說我應該使用以下兩種方法之一禁用跨源請求:

-禁用網絡安全

--allow-文件訪問從檔案**

我在命令提示符中嘗試了這兩個:

C:\Users\danniu>C:\Users\danniu\AppData\Local\Google\Chrome\Application\Chrome.e
xe --allow-file-access-from-files

C:\Users\danniu>C:\Users\danniu\AppData\Local\Google\Chrome\Application\Chrome.e
xe --disable-web-security

當我嘗試在Chrome中運行游戲時,我仍然收到此錯誤:

XMLHttpRequest cannot load file:///C:/Users/danniu/Desktop/JavaScript/melonJS/data/map/area01.tmx. Cross origin requests are only supported for HTTP.

我究竟做錯了什么?

謝謝

您需要使用這兩個參數。 這是我在我的Mac上運行它的方式。

open -a Google\ Chrome --args --disable-web-security -–allow-file-access-from-files

這是它應該如何為Windows:

"C:\PathTo\Chrome.exe" –allow-file-access-from-files -disable-web-security

要在mac上禁用chrome web security,請在終端上使用此命令

$ / Applications / Google \\ Chrome.app/Contents/MacOS/Google \\ Chrome --user-data-dir =“/ tmp / chrome_dev_session”--disable-web-security

如果$ open -a Google \\ Chrome --args --disable-web-security --allow-file-access-from-files不會有幫助

您應該通過HTTP協議請求

這是一個非常簡單的答案: https//stackoverflow.com/a/23118676/1585438

反SOP參數: - --disable-web-security -–allow-file-access-from-files

要使參數生效,不得運行另一個chrome實例。 如果您已經運行了chrome並使用反SOP參數啟動新實例,則它將無效。

關閉鑲邊時,請確保關閉所有實例。 這包括沒有GUI的實例 (任務管理器是你的朋友)!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM