Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox refuses a relative path for local files

Tags:

firefox

I load a local html file from my windows 7 filesytem :

 file:///C:/Users/...etc.../myfile.html

Inside it, an existent file relative to the directory of myfile.html :

 ....load("../common/events.json");

Firefox refuses it, error at console :

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote 
    resource at file:///C:/Users/...etc.../common/events.json?timeshift=-60. (Reason: CORS request not http).

With link : https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp

So I set privacy.file_unique_origin to false in config and restarted Firefox : same issue

NB all is ok with ... IE 11 !

like image 419
troubadour Avatar asked Nov 02 '25 14:11

troubadour


1 Answers

You could start your own local server:

python3 -m http.server

which tells you the port (e.g. Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/)).

Then something enter in browser address bar something like http://0.0.0.0:8000/C:/Users/...etc.../myfile.html.

The path is relative to the location where the server was started.

like image 133
Friedrich Avatar answered Nov 04 '25 15:11

Friedrich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!