12

I am using Backbone.LocalStorage plugin with backbone app. It is working fine in chrome and safari however, it is giving me below error in firefox.

DOMException [SecurityError: "The operation is insecure." code: 18 nsresult: 0x80530012 location: http://localhost:8000/js/libs/backbone.localStorage/backbone.localStorage.js?version=1453910702146:137]

I am using python simpleHttpServer

How can I resolve this error?

UPDATE

Here is my code.

paths: {
    'jquery'        : 'libs/jquery/dist/jquery',
    'underscore'    : 'libs/underscore/underscore',
    'backbone'      : 'libs/backbone/backbone',
    'localStorage'  : 'libs/backbone.localStorage/backbone.localStorage',
    'text'          : 'plugins/text'
}

Here is collection where localStorage is used.

var Items = Backbone.Collection.extend({

    model: SomeModel,

    localStorage: new Backbone.LocalStorage('items'),
});

UPDATE 2

I am using firefox 36.

UPDATE 3

It seems like it is a CORS issue but my firefox version is 36. Which should be fine.

UPDATE 4

I am also getting this error in firefox nightly version 44. I also updated my firefox to version 44. Still same error.

Om3ga
  • 30,465
  • 43
  • 141
  • 221

4 Answers4

5

Make sure Firefox has cookies enabled. The setting can be found under Menu/Options/Privacy/History

In the dropdown, select either 'Remember History' or if You prefer use custom settings for history, but select option Accept cookies from sites

Hope it helps.

J Foley
  • 1,038
  • 1
  • 17
  • 30
Daniel
  • 1,364
  • 1
  • 11
  • 18
4

This happens when we try to access a resource (CSS...) that is located on a different domain. To deal with this error we can use this:

                   try {
                     //your critical access to ressources !
                     //rules = document.styleSheets[i].cssRules;
                        } catch(e) {
                   if(e.name !== "SecurityError") {
                       throw e;
                       }
max
  • 23
  • 2
  • 6
mkebri
  • 2,025
  • 1
  • 16
  • 14
1

Make sure your domains are same. verify Same Origin Policy which means same domain, subdomain, protocol (http vs https) and same port.

What is Same Origin Policy?
How does pushState protect against potential content forgeries?

Community
  • 1
  • 1
Venkat.R
  • 7,420
  • 5
  • 42
  • 63
  • 1
    I know it is the problem of Same Origin Policy however, I am not sure how can I resolve this? I also don't see why this occurs because I am not sending any request to another domain. All resources are in same domain i.e. localhost in this case. – Om3ga Jan 27 '16 at 19:30
  • place your code snippet in your question to proceed further – Venkat.R Jan 28 '16 at 01:50
0

I had similar issue with one script, I dig into error and found it required SSL websockets, so I started SSL and again checked, and It worked. Try enabling HTTPS and access website as https://127.0.0.1/ It may solve error.

Jitendra
  • 1,107
  • 2
  • 12
  • 22