Akryum / Akryum/vue-cli-plugin-apollo

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

未关闭
#422 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
477
派生
109
PR 合并指标
30 天内没有已合并 PR

描述

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.)

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。