Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to disable Chrome same origin policy

I'm trying to follow a melonJS tutorial. It says I should disable cross-origin request using one of two methods:

--disable-web-security

--allow-file-access-from-files**

I've tried both of these in my command prompt as such:

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

When I try to run the game in Chrome I'm still getting this error:

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

What am I doing wrong?

Thanks

like image 775
user3871 Avatar asked Feb 25 '14 21:02

user3871


People also ask

What is same-origin policy in chrome?

The same-origin policy is a critical security mechanism that restricts how a document or script loaded by one origin can interact with a resource from another origin.

How do I fix cross-origin issues in chrome?

i. Turn OFF the CORS plugin, reload the app, at this time you should still get the errors which are correct. ii. Turn it back ON, reload the app, if the APIs are successful, stop here, no need to proceed to iii.

How do I enable access control allow origin on chrome?

Allow CORS: Access-Control-Allow-Origin. Easily add (Access-Control-Allow-Origin: *) rule to the response header. Allow CORS: Access-Control-Allow-Origin lets you easily perform cross-domain Ajax requests in web applications. Simply activate the add-on and perform the request.


2 Answers

You need to use both arguments. This is how I run it on my mac.

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

This is how it should be for windows:

"C:\PathTo\Chrome.exe" –allow-file-access-from-files -disable-web-security
like image 136
JJJ Avatar answered Oct 12 '22 20:10

JJJ


To disable chrome web security on mac use this command on terminal

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

if $ open -a Google\ Chrome --args --disable-web-security -–allow-file-access-from-files dosen't help

like image 20
Himanshu Sharma Avatar answered Oct 12 '22 20:10

Himanshu Sharma