Beginners who are fiddling with Chromium based programs often encountered the "Not allowed to load local resource" error message.
In this article, we’ll demonstrate a quick fix that you can use every time you encounter "Not allowed to load local resource".
Method 1 : Disable Chrome built-in security measures
Now that we know what the error message actually means, we can formulate a solution to it.
If you’re just fiddling around, consider disabling this specific Chrome security measure.
Please note that the security exception exist for good reasons and trying to circumvent them isn’t a good idea, especially in production environment.
To disable "Not allowed to load local resource" exception, you will have to pass a few flags to the execution. The command should be something like this
/path/to/chrome_binary –allow-file-access-from-files -disable-web-security
/path/to/chrome_binary can be quoted if it contains special characters.
To make the parameters effective, there must not be another instance of chrome running. If you have chrome running already and start a new instance with the anti-SOP parameters, it will have no effect. Please make sure that all instances are closed, include instances without GUI as well.
Method 2 : Run a simple server serving static files
An alternative for disabling Chrome security features is running a simple server serving files from your local machine.
Sure, you can spin up a new remote machine for this purpose, but it would be overkill, and you have to deal with managing a full-fledged web server. On top of that, the latency adds one or two seconds every time you reload the page.
If you’re using Chrome or Chrome-based browsers, you can install Web Server for Chrome from the Chrome Web Store. The extension runs off-line and has the ability to spin off a simple server serving files from a local directory over the network through HTTP.
You can’t use PHP or any other web development stack in conjunction with it, but for static files, this extension works fine. Web Server for Chrome even supports CORS methods.
Remember to use the URL from your web server instead of a file URL (file://). You should also use HTTP URLs as HTTPs could cause mixed content security warnings.
Run a web server and put your files in there. Use the URL to serve files through your web server, not the file:// URL.