Cookie 未随 Web 应用请求一起发送 manifest.json
Cookies not sent with request for Web App manifest.json
我正在尝试在需要身份验证(通过 Cookie 管理的登录令牌)的网站上启用 PWA。
我正在本地 (http://localhost:4502) 尝试此操作并登录网站(并获得登录 cookie)。
问题是在请求 Web 应用程序清单时,没有针对请求发送 Cookie,因此请求未通过身份验证。
<link rel="manifest" href="/content/site-x/manifest.json">
如您所见,清单的提供方式与包含它的网页相同host/scheme。
清单请求是否传递了 cookie?我什至将我的登录 cookie 设置得尽可能宽松,但什么也没有。 cookie 是在所有其他请求(JS、CSS 等)上发送的——localhost 是否有什么特别之处?或者它不是 http?
好像有个old a bug in chromium,这些年应该修好了。或许你可以尝试使用 ajax/fetch
the "/content/site-x/manifest.json" with requestHeader "Content-type: application/json"
然后从中创建一个 Blob 然后调用 createObjectURL(Blob) 并给这个 url 到 href?
然后还有这个:
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
我想这对你的情况没有帮助,因为你是同一个来源。
根据 https://developers.google.com/web/fundamentals/web-app-manifest/
The request for the manifest is made without any credentials (even if it's on the same domain), thus if the manifest requires credentials, you must include crossorigin="use-credentials" in the manifest tag.
因此为两个跨域添加 <link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
就像在清单请求中添加服务器 cookies
我正在尝试在需要身份验证(通过 Cookie 管理的登录令牌)的网站上启用 PWA。
我正在本地 (http://localhost:4502) 尝试此操作并登录网站(并获得登录 cookie)。
问题是在请求 Web 应用程序清单时,没有针对请求发送 Cookie,因此请求未通过身份验证。
<link rel="manifest" href="/content/site-x/manifest.json">
如您所见,清单的提供方式与包含它的网页相同host/scheme。
清单请求是否传递了 cookie?我什至将我的登录 cookie 设置得尽可能宽松,但什么也没有。 cookie 是在所有其他请求(JS、CSS 等)上发送的——localhost 是否有什么特别之处?或者它不是 http?
好像有个old a bug in chromium,这些年应该修好了。或许你可以尝试使用 ajax/fetch
the "/content/site-x/manifest.json" with requestHeader "Content-type: application/json"
然后从中创建一个 Blob 然后调用 createObjectURL(Blob) 并给这个 url 到 href?
然后还有这个:
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
我想这对你的情况没有帮助,因为你是同一个来源。
根据 https://developers.google.com/web/fundamentals/web-app-manifest/
The request for the manifest is made without any credentials (even if it's on the same domain), thus if the manifest requires credentials, you must include crossorigin="use-credentials" in the manifest tag.
因此为两个跨域添加 <link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
就像在清单请求中添加服务器 cookies