able to run my backbone js project on localhost,not able to run locally in chrome browser

1.2k views Asked by At

I am able to run my backbone js project on localhost, but when i run index.html page directly it is giving access-control-allow-origin error only in chrome browser, in firefox it is working fine in both the cases.

1

There are 1 answers

6
deitch On BEST ANSWER

I assume that you have ajax requests to sync the Backbone Models with the server, and when you say "on localhost" you mean "with a server running on my localhost and my browser connects to 127.0.0.1:<someport>", and when you say, "run index.html directly" you mean "launch it in the browser as file://path/to/index.html, correct?

If I recall correctly, Chrome does not allow you to access file: URLs via ajax as if they were network requests. Firefox did that for some release (cannot recall which at the moment), but there was pushback, it was made an option, then they reenabled it (based on my recollection).

Just run it with a server locally, using nodejs or thin or whatever language your server is written in.