micro-zoe / micro-app

A simple, efficient and powerful micro front-end framework. 一款简约、高效、功能强大的微前端框架
https://micro-zoe.github.io/micro-app/
MIT License
5.62k stars 570 forks source link

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

Open Horoll opened 10 months ago

Horoll commented 10 months ago

主应用electron13.2.2 + vue2,子应用vue3+vite,micro-app1.0.0-rc。采用iframe模式,在开发环境使用没有问题,打包后报错:Failed to read the 'localStorage' property from 'Window' : Access is denied for this document,去除子应用种的localStorage也会报cookie的相同错误。

已尝试以下解决方案,都未解决该问题:

1、 关闭micro-app沙箱模式:disable-sandbox

2、 electron app组件的ready事件后添加:

app.commandLine.appendSwitch('disable-site-isolation-trials')

禁用站点隔离。

3、 注册标准schemes

protocol.registerSchemesAsPrivileged([{

scheme: 'app',

privileges: {

secure: true,

supportFetchAPI: true,

standard: true

}

}])

非标准schemes下,网络存储Api(localStorage,sessionStorage,webSQL,indexedDB,cookies)默认被禁用。

bailicangdu commented 10 months ago

这涉及到浏览器权限设置吧

JamesSky commented 7 months ago

遇到了同样的问题