This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Mike Johnson
Posted Sep 28 - Read on Facebook

I feel like I have solved this before, but I am running into a cross origin error when converting the app.coffee to app.js and trying to host locally. The following error shows up in the console:

file:///F:/imported/[email protected]/layers.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

I know I should use a server, or disable origin rules on chrome or safari (which does work) however in this specific case I am loading the html file in another way and can't do either... I don't have control over how the html gets consumed (local vs server)

Is there any way to make it work from the file itself? Can I use JSONP somehow in this odd case? Is it because I'm accessing it from another drive on Windows? (F:\)

5 Comments

Benjamin Den Boer

Hmm, Koen Bok / Eelco?

Koen Bok

So yes and no. First the no; there is no way to do xhttp requests if you have a file:// url. That is a sensible (but annoying) security measure in browsers.

The way to hack around it is to have a JavaScript file with all the data in there, and just expose it in some variable. Because JavaScript files load fine locally. We actually already do this in some cases (look for the layers.json.js file in your imports).

Mike Johnson

I see. So currently I am making a new folder, using framer.js with app.js that I am compiling in atom from a copy paste within studio.

Works very well until i try to use the importer for sketch, where I copy the imported folder. It seems Utils.coffee is the on throwing the error from the sketch import.

Mike Johnson

Is there a better world for quickly iterating in studio and creating f a self contained locally safe html file using framer.js?

Mike Johnson

Figured out that I actually need to also include the framer.generated.js file as well. Once that is in it used the json as js and everything started working fine.

Read the entire post on Facebook