chrome系浏览器报错跨域问题:The request client is not a secure context and the resource is in more-private address space `privat
chrome 102版本新增特性,导致如果域名ip变更或者使用vpn报错
https://juejin.cn/post/7111190533942280206#heading-0
解决方案:
- 使用Chrome低版本或其他浏览器。
- 将网站升级为https。
- 在Chrome浏览器地址栏搜索chrome://flags,然后在搜索框搜索Block insecure private network requests,最后将其Default改为Disabled。
或者可以使用js强制刷新页面解决
// isPNA.js
function clearCache(reloadAfterClear = true) {
if('caches' in window){
caches.keys().then((names) => {
names.forEach(async (name) => {
await caches.delete(name)
})
})
if(reloadAfterClear) {
window.location.reload()
}
}
}
if (typeof window !== 'undefined') {
const pna = sessionStorage.getItem('pna-clearCache')
console.log('pna', pna)
if (!pna) {
// window.location.replace(window.location.href)
clearCache()
sessionStorage.setItem('pna-clearCache', true)
}
}
// _document.js
<script src="/group/isPNA.js"></script>
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!