I tried loading Ace editor from an HTML file on my computer (using file:///
protocol) to edit JavaScript:
ace.edit("editor", {
"mode": "ace/mode/javascript",
})
However, CSP blocks a worker used by JSHint (which Ace implements by default). The following error is logged to the console:
Content Security Policy: The page’s settings blocked the loading of a resource at blob:null/[...] (“worker-src”).
When I set loadWorkerFromBlob
to false
:
ace.config.set("loadWorkerFromBlob", false)
A different error was generated:
Security Error: Content at file:///[...]/index.html may not load data from file:///[...]/ace/worker-javascript.js.
I tried to bypass CSP with <meta http-equiv="Content-Security-Policy">
but to no avail, and searching this problem yielded no results.
How can I use JSHint in Ace editor from a local HTML page?
Edit: Forgot to specify that this is only a problem with Firefox. The first example worked completely fine for me on Chromium.