Jump to content

Chrome: File System (without server) Testing


mrBRC
 Share

Recommended Posts

This is relevant to the downloadable framework tutorials/demos and a general chrome testing FAQ

You can bypass/disable the web security of Chrome to test applications that might otherwise violate a same origin security policy enforced by the browser.

 


Create a shortcut on your desktop to chrome passing the -disable-web-security switch
(ex: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security)

 

All chrome.exe processes must be closed before opening chrome with that shortcut/added switch

 

Close all running Chrome.exe instances and applications.. Chrome Extensions could still be running in the background, so verify with a Running Task/Process Explorer.

 

 

.. of course, I wouldn't recommend browsing the web with it though..

Link to comment
Share on other sites

If all you want is being able to access local files and run local scripts, you may consider using --allow-file-access-from-files, which is less dangerous if you accidentally leave it on while browsing the web

Link to comment
Share on other sites

  • 3 weeks later...

This is relevant to the downloadable framework tutorials/demos and a general chrome testing FAQ

 
I agree, this should be explained in the FAQ and in the common issues, as this was the first problem I ran into when starting with Phaser. I think this even bypasses the need to install a complete webserver just to run some local html+js files. Here is a proposed text explaining the issue and the solution:
----
When you download an example game to your local harddisk and open it in Chrome, you might see just a black screen with nothing happening. Press CTRL+SHIFT+J to view the javascript console, and you might see the following error or variations of it, for example:
XMLHttpRequest cannot load file:///C:/phaser_demos/assets/games/tanks/tanks.png. Cross origin requests are only supported for HTTP. 

This is because Chrome, by default, does not allow any webpage to open files from your local harddisk as this poses a potential security risk. However, if you want to try a downloaded example game or debug your own Phaser project using Chrome you can bypass this by starting Chrome with the parameter "--allow-file-access-from-files". So either create a shortcut or a batch file with the following command line (location of chrome.exe may vary depending on your Windows configuration).

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files

Check the task manager before starting the shortcut or batchfile to make sure that there aren't any Chrome sessions still running. Open the Phaser game in this 'special' Chrome session and it should now run without any problems.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...