What error "Not allowed to load local resource" is about?

72,779 views
Skip to first unread message

Alexander Myltsev

unread,
Jun 10, 2014, 7:17:47 AM6/10/14
to scal...@googlegroups.com
Hi there!

I have error while running JavaScript as follows:



How should I interpret this error? What is wrong with my project?

A.

Gleb Kanterov

unread,
Jun 10, 2014, 7:46:14 AM6/10/14
to scal...@googlegroups.com
Hi,

Probably you open index.html with file:// protocol, Chrome default security policy doesn't allow you to open local files except one that you have in window.location.

I suggest to use http://, something like "python -m SimpleHTTPServer" and "open http://localhost:8000".

Gleb

Haoyi Li

unread,
Jun 10, 2014, 7:49:59 AM6/10/14
to Gleb Kanterov, scal...@googlegroups.com
workbench comes with a localhost HTTP server for this purpose. Running HTML files as standalone works in theory but is a huge headache in practice.


--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alexander Myltsev

unread,
Jun 11, 2014, 4:13:17 AM6/11/14
to scal...@googlegroups.com, gl...@kanterov.ru
Gleb, python server resolved the issue.

Li, workbench seems very useful. For me it just did not work out of the box. I left you some issues concerned. Looking forward them to be resolved. 

A.

Jakub Liska

unread,
Sep 22, 2014, 10:16:42 AM9/22/14
to scal...@googlegroups.com, gl...@kanterov.ru
Until google-chrome Version 37.0.2062.120 I've been using 

google-chrome-stable --disable-web-security --allow-file-access-from-files

but now it doesn't work anymore, so I'm facing this problem again. The chrome extension for this purpose doesn't work either..

Justin du coeur

unread,
Sep 22, 2014, 10:20:24 AM9/22/14
to Jakub Liska, scal...@googlegroups.com, gl...@kanterov.ru
Keep in mind, you're trying to work around something that is explicitly and deliberately illegal in all modern web browsers.  It's usually advisable to run a local web server instead of trying to hack the problem.  (I hadn't realized that Chrome had had a flag to turn this off, but it's not a good habit to get into anyway...)

--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.

Jakub Liska

unread,
Sep 22, 2014, 10:26:16 AM9/22/14
to scal...@googlegroups.com, liska...@gmail.com, gl...@kanterov.ru
Keep in mind, you're trying to work around something that is explicitly and deliberately illegal in all modern web browsers.

Who would give a damn about security when developing an app in a development environment ... I'm not gonna release the application with scalajs workbench with README.txt saying : "you must run chrome with flags : --disable-web-security --allow-file-access-from-files"

Justin du coeur

unread,
Sep 22, 2014, 10:41:35 AM9/22/14
to Jakub Liska, scal...@googlegroups.com, gl...@kanterov.ru
Huh -- I haven't used workbench, but I'm surprised: I thought it included its own webserver for just this reason...

On Mon, Sep 22, 2014 at 10:26 AM, Jakub Liska <liska...@gmail.com> wrote:
Keep in mind, you're trying to work around something that is explicitly and deliberately illegal in all modern web browsers.

Who would give a damn about security when developing an app in a development environment ... I'm not gonna release the application with scalajs workbench with README.txt saying : "you must run chrome with flags : --disable-web-security --allow-file-access-from-files"

--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.

Jakub Liska

unread,
Sep 22, 2014, 11:45:56 AM9/22/14
to scal...@googlegroups.com, liska...@gmail.com, gl...@kanterov.ru
Yup, ScalaJS is expecting that you are opening html via file:// as it maps generated javascript to its source file also via file://. It is not compatible with workbench using web server though cause scalaJS is still trying to map to sources via file://, which is not possible from a file served via web server where the security policy applies.

Sébastien Doeraene

unread,
Sep 22, 2014, 11:49:48 AM9/22/14
to Jakub Liska, scal...@googlegroups.com, gl...@kanterov.ru
Hi,

Use the `relativeSourceMaps` sbt setting for that purpose. You should find a few discussions about this on the ML, already.

Sébastien.

On Mon, Sep 22, 2014 at 5:45 PM, Jakub Liska <liska...@gmail.com> wrote:
Yup, ScalaJS is expecting that you are opening html via file:// as it maps generated javascript to its source file also via file://. It is not compatible with workbench using web server though cause scalaJS is still trying to map to sources via file://, which is not possible from a file served via web server where the security policy applies.

--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.

Justin du coeur

unread,
Sep 22, 2014, 11:50:06 AM9/22/14
to Jakub Liska, scal...@googlegroups.com, Gleb Kanterov
Hmm -- that's odd, since it works fine in the standard Play skeleton.  Do you have "relativeSourceMaps := true" in your sbt file?

On Mon, Sep 22, 2014 at 11:45 AM, Jakub Liska <liska...@gmail.com> wrote:
Yup, ScalaJS is expecting that you are opening html via file:// as it maps generated javascript to its source file also via file://. It is not compatible with workbench using web server though cause scalaJS is still trying to map to sources via file://, which is not possible from a file served via web server where the security policy applies.

--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.

Jakub Liska

unread,
Sep 22, 2014, 12:35:13 PM9/22/14
to scal...@googlegroups.com, liska...@gmail.com, gl...@kanterov.ru
The relativeSourceMaps work when starting JS app via launcher, when not using launcher but just :
 
<script>MyApp().main();</script>

then I don't know how to make it work, I tried several things without success. I don't even need it now. I'm just saying for future reference...

Benjamin Jackman

unread,
Sep 24, 2014, 12:37:18 AM9/24/14
to scal...@googlegroups.com, gl...@kanterov.ru
Just a helpful tip, if you are using a system with python on it:

Don't use file://xxxxx for local webdev, this is usually a lot easier:

python -m SimpleHTTPServer 8080

It will serve files from the current folder on port 8080 which works a lot better with the cross-domain restrictions.

Justin du coeur

unread,
Sep 24, 2014, 8:11:34 AM9/24/14
to Jakub Liska, scal...@googlegroups.com, Gleb Kanterov
*Very* odd, since AFAIK the launcher is just a fancier version of that statement.  Have you tried copy/pasting the text of the launcher file and seeing what happens?

Jakub Liska

unread,
Sep 24, 2014, 9:30:32 AM9/24/14
to scal...@googlegroups.com, liska...@gmail.com, gl...@kanterov.ru
I don't need it... but practically there are 2 reasonable options - the relative paths in xxx.js.map should correspond to index.html location or to generated xxx.js file, I tried both... But as I said, I don't need it thus I won't be trying anything else anymore, nor discussing it here :-)

Kat H4xor

unread,
Nov 8, 2019, 11:54:03 AM11/8/19
to Scala.js
Hello
How can I open this:
chrome://extensions
I'm making a chrome extensions which will open the Extensions page with a hotkey
Thanks very much.
Reply all
Reply to author
Forward
0 new messages