This tutorial shows you how to disable same-origin policy in Google Chrome
The same origin policy is a preventing malicious scripts to access the data on different web page
Disabling this policy only has some serious issues even in development. It is not advisable to do it permanently
This is used when you are accessing a webpage that contains script files from iframe.
How to disable Same Origin Policy in Chrome browser.
There are multiple ways to open a Chrome browser in different OS.
The below properties need to pass to Chrome in the command line.
--allow-file-access-from-files
: Files such as JSON can be accessed using AJAX in development for testing the web pages.--user-data-dir=path
:
this stores the webpage resources in the directory or path given. Please make sure that this directory has permission to read and write from Chrome.--disable-web-security
:
It disables web security to access resources one page to another page resource such as iframes
--disable-site-isolation-trials
: Open Chrome in Sandbox
You can use one or many options based on Chrome version and OS specific.
For Window users
Open the Command line or Windows + R and type Run
Run the below command
chrome.exe --disable-site-isolation-trials --disable-web-security
Some versions only work with --disable-web-security
arg, Latest versions support adding disable-site-isolation-trials
.
It opens the chrome browser with a disable security policy.
For Linux, Ubuntu users, Open terminal Run the below command to open Chrome with disable policy
google-chrome --disable-site-isolation-trials --user-data-dir=/tmp --disable-web-security
For mac users Open terminal Run the below command to open Chrome with disable policy
open -a "Google Chrome" --disable-site-isolation-trials --args --disable-web-security --user-data-dir