rstacruz/flatdoc

Local file fetch does not work in Chrome

drasko opened this issue · 2 comments

Hi all,
trying template.html with local file Readme.md

<script> Flatdoc.run({ fetcher: Flatdoc.file('Readme.md') }); </script>

I am getting:

Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. file:///home/drasko/Readme.md
XMLHttpRequest cannot load file:///home/drasko/Readme.md. Origin null is not allowed by Access-Control-Allow-Origin. template.html:1
[Flatdoc] fetching Markdown data failed.
Object
flatdoc.js:16
Blocked a frame with origin "http://ghbtns.com" from accessing a frame with origin "null". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "file". Protocols must match.

Hi all,
I have noticed that Chromium can be run with following flags to override this problem:
drasko@Lenin:~$ chromium --no-first-run --no-default-browser-check --allow-file-access-from-files --temp-profile --allow-external-pages --allow-file-access --user-data-dir=.

--user-data-dir switch is necessary to prevent Chromium using default profile and ignoring the rest of the switches.

Enabled switches can be checked from Cromium at addr chrome://version, as described here: http://askubuntu.com/questions/160245/how-do-i-make-the-google-chrome-flag-allow-file-access-from-files-permanent

Hope this helps to someone else also.

The --allow-file-access-from-files also works on Chrome.

On a mac just do:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --allow-file-access-from-files