Currently with a service worker caching pages, HTTP Basic Auth is broken. Upon initial load a user will be prompted for credentials, however, due to caching, this prompt will never be shown a second time unless the user clears their cache.
Originally filed as a chromium bug here: https://bugs.chromium.org/p/chromium/issues/detail?id=623464
Though this appears to be an intentional "feature" to prevent random credential requests.
I am not sure what the proper solution to this is, though a possible workaround is outlined here: https://thatemil.com/blog/2018/02/21/pwa-basic-auth/
Additional workbox support is needed at this point before addressing this issue.
@manniL see above.
@pi0 I messed up the template. Please reopen and change to bug / feature request.
This is undocumented fixed in https://github.com/nuxt-community/pwa-module/blob/11795599edccb1b9beae892c71a6f8db0d76da9c/packages/manifest/index.js#L75 , just provide crossorigin: 'use-credentials' in your manifest section of nuxt.config.js
Added to the docs for next version.
Added to the docs for next version.
@pi0 what docs do you mean? because in the official site https://pwa.nuxtjs.org/modules/manifest.html, I couldn't find anything related to this issue, and I really think a lot of people could benefit from having it there and avoiding having to google the problem and end up in this thread.
@fernhub It's right here: https://pwa.nuxtjs.org/modules/workbox.html#basic-auth
@pi0
Even with the proposed fix I am experiencing the issue. Crossorigin is set correctly in index.html.
<link data-n-head="1" rel="manifest" href="/_nuxt/manifest.c09e73a7.json" crossorigin="use-credentials">
Registering the routes causes the issue:
workbox.routing.registerRoute(new RegExp('/'), new workbox.strategies.NetworkFirst (), 'GET')
When setting offline: false to remove them the login prompt appears as intended.
The request workbox sent (from debug mode):
method: "GET"
url: "https://****.***/"
headers: Headers {}
destination: "document"
referrer: ""
referrerPolicy: "no-referrer-when-downgrade"
mode: "navigate"
credentials: "include"
cache: "default"
redirect: "manual"
integrity: ""
keepalive: false
signal: AbortSignal {aborted: false, onabort: null}
isHistoryNavigation: false
bodyUsed: false
Am I missing anything?
I'm on
"@nuxtjs/pwa": "^3.0.0-beta.20"
Chrome v. 80.0.3987.149
Most helpful comment
This is undocumented fixed in https://github.com/nuxt-community/pwa-module/blob/11795599edccb1b9beae892c71a6f8db0d76da9c/packages/manifest/index.js#L75 , just provide
crossorigin: 'use-credentials'in your manifest section of nuxt.config.js