progressive-web-apps - php 脚本中标头重定向的 Service Worker 配置
问题描述
语言使用 php、html 和 js。我创建了一个只能通过 POST 完美运行的服务工作者脚本。当我尝试制作 header("Location: " . $MM_redirectLoginSuccess,TRUE,302); 其中 $MM_redirectLoginSuccess 是“aaaa.php”;应用程序循环 GET 和状态被取消,只要浏览器挂起错误太多重定向!。这是我可以从开发人员面板的网络选项卡中获得的。
fetch("https://xxxx.aaaa.php", {
"referrer": "https://xxxx/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "omit"
});
请问如何避免这个问题?上面的 fetch 插入到 ServiceWorker-->
self.addEventListener('fetch', event => {
// Prevent the default, and handle the request ourselves.
event.respondWith(async function() {
// Try to get the response from a cache.
const cachedResponse = await caches.match(event.request);
// Return it if we found one.
if (cachedResponse) return cachedResponse;
// If we didn't find a match in the cache, use the network.
return fetch(event.request);
}());
});
解决方案
推荐阅读
- json - 使用 Kotlinx.Serialization 解析嵌套的 JSON
- wordpress - 在 wpallexport 中显示高级自定义字段
- list - 提取列表中两个值之间的项目列表 - prolog
- angular - 在 Angular 7 中使用 SJCL 时无法解析 './node_modules/sjcl' 中的 'crypto'
- python - 如何防止二分布局将边缘绘制到孤立节点?
- html - 使用 DIV 包装器缩放内联 SVG
- pandas - 如何选择满足条件的列名称
- python - 我如何在 python django 的 html 中使用小于或大于符号
- typescript - 选择器“.exits”和“.visible”之间的Testcafe差异
- php - 可以读取 cookie 并在 mysql SELECT Query 中使用