Next-pwa: dynamicStartUrl caused chrome to goes offline after first redirection

Created on 8 Apr 2021  路  7Comments  路  Source: shadowwalker/next-pwa

Summary

When setting dynamicStartUrl: true option, the new installability check in Chrome 89 disappeared, visitting start-url got redirected correctly as intended. But when I tried to visit the start-url again after the first redirection, it won't open the page and chrome's offline page was shown instead.

Chrome's DevTool also show this warning

The FetchEvent for "http://localhost:3000/" resulted in a network error response: a redirected response was used for a request whose redirect mode is not "follow".
Promise.then (async)
(anonymous) @ Router.js:58

How To Reproduce

I've created a minimal repro here: https://github.com/panjiesw/pwa-repro with this next.js.config

const withPWA = require('next-pwa');

module.exports = withPWA({
  pwa: {
    dest: 'public',
    dynamicStartUrl: true,
  },
});

Steps to reproduce the behavior:

  1. Clone the repo above
  2. Run yarn dev (or yarn build then yarn start)
  3. Go to http://localhost:3000
  4. You'll be redirected to http://localhost:3000/login
  5. Re-visit http://localhost:3000 again
  6. Chrome's offline page will be shown

Expected Behaviors

Users should still be able to re-visit start-url after they got redirected when using dynamicStartUrl instead of shown Chrome's offline page.

Screenshots

Chrome DevTool warning:

2021-04-08-222232_4480x1440_scrot

Chrome offline page:

2021-04-08-222342_4480x1440_scrot

Additional Context

My PWA require a redirection from start-url (/) to a login page if not authenticated (handled server side in Next.js). Before, the PWA got Chrome's warning that it won't be installable in Chrome 93 onwards, so I'm trying dynamicStartUrl feature in next-pwa.

bug

All 7 comments

Update: Seems like it's also causing error in Firefox

pwa_ff_console

pwa_ff_error

Update Environment:

  • Node.js v14.5.4
  • Next.js v10.1.3
  • next-pwa v5.2.3

Update: found a response for your workaround here: https://github.com/GoogleChrome/workbox/issues/2749#issuecomment-813489953, do you suggest to not enable dynamicStartUrl for now? Since the offline check likely will get improvement in Chrome anyway

I'm seeing a similiar issue on iOS Safari 12-14.x with next-pwa v5.1.4. Looks like dynamicStartUrl became the default in https://github.com/shadowwalker/next-pwa/commit/c6416215bcdec6cc49540259f47863f14ea8f39d

FetchEvent.respondWith received an error: no-response: no-response :: [{"url": ...

@shadowwalker thanks using dynamicStartUrlRedirect works! But seems like there is console.log statement here https://github.com/shadowwalker/next-pwa/blob/f9955c26dbd092e262f457a20bc9a2f46295fd03/register.js#L5

Is that a left over from development or an intended one? It's shown even in production build.

Version 5.2.7 should fix this problem.

Sorry for not getting back sooner. I've confirmed that the issue has been fixed using latest version, thanks @shadowwalker!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sugar3103 picture sugar3103  路  8Comments

TrejoCode picture TrejoCode  路  6Comments

mohammadgarmroodi picture mohammadgarmroodi  路  5Comments

rrjanbiah picture rrjanbiah  路  6Comments

loyep picture loyep  路  3Comments