Akryum / Akryum/vue-cli-plugin-apollo

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

Open
#422 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
477
Forks
109
PR merge metrics
No merged PRs in 30d

Description

Through Sentry I've noticed one of my users is running into the following error:
```
Network error: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
```
It seems to originate from [defaultGetAuth accessing localStorage](https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/graphql-client/src/index.js#L217)

It's triggered when a user has disabled third party cookies and a site with an iframe loads a site from a different domain that uses localStorage. Lovely combination of circumstances. More info:
- https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document
- https://stackoverflow.com/questions/30481516/iframe-in-chrome-error-failed-to-read-localstorage-from-window-access-deni

localStorage access should always include some checks. For Safari in private mode you even need a try catch:
https://stackoverflow.com/questions/35607724/ios-safari-private-browsing-localstorage-and-sessionstorage-support/43670472

(I know the vue-apollo.js file also uses localStorage in `onLogin` and `onLogout`, but I'm not using those.)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.