debugjavascriptCritical
"Cross origin requests are only supported for HTTP." error when loading a local file
Viewed 0 times
errorloadingaresupportedforonlywhenfilelocalorigin
Problem
I'm trying to load a 3D model, stored locally on my computer, into Three.js with JSONLoader, and that 3D model is in the same directory as the entire website.
I'm getting
Cross origin requests are only supported for HTTP.
but I don't know what's causing it or how to fix it.
I'm getting
Cross origin requests are only supported for HTTP.
but I don't know what's causing it or how to fix it.
Solution
My crystal ball says that you are loading the model using either
So you can either install a webserver in your local PC or upload the model somewhere else and use
Origin is defined in RFC-6454 as
[...]they have the same scheme, host, and port. (See Section 4 for full details.)
So even though your file originates from the same host (
file:// or C:/, which stays true to the error message as they are not http://So you can either install a webserver in your local PC or upload the model somewhere else and use
jsonp and change the url to http://example.com/path/to/modelOrigin is defined in RFC-6454 as
[...]they have the same scheme, host, and port. (See Section 4 for full details.)
So even though your file originates from the same host (
localhost), but as long as the scheme is different (http / file), they are treated as different origin.Context
Stack Overflow Q#10752055, score: 957
Revisions (0)
No revisions yet.