pinqy520 / mobx-persist

persist mobx stores
MIT License
560 stars 62 forks source link

Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document. #59

Open corymsmith opened 6 years ago

corymsmith commented 6 years ago

This error happens when someone has this option disabled in Chrome:

screenshot 2018-09-28 09 42 22

I am trying to use a memory storage from local-storage-fallback in the case that people have disabled cookies, etc. but an error is thrown inside mobx-persist when accessing localStorage here: https://github.com/pinqy520/mobx-persist/blob/master/src/index.ts#L41

This is the code I'm using:

const { storage } = require('local-storage-fallback');
const hydrate = create({ storage, jsonify: true });
hydrate('checkout-store', this).then(() => {

});

This is the error thrown: Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

grantspilsbury commented 3 years ago

Hey @corymsmith did you ever find a solution for this?

corymsmith commented 3 years ago

@grantspilsbury

I ended up having to use the following:

const { storage } = require('local-storage-fallback');