Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamicStartUrl caused chrome to goes offline after first redirection #194

Closed
panjiesw opened this issue Apr 8, 2021 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@panjiesw
Copy link

panjiesw commented Apr 8, 2021

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.

@panjiesw panjiesw added the bug Something isn't working label Apr 8, 2021
@panjiesw
Copy link
Author

panjiesw commented Apr 8, 2021

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

@panjiesw
Copy link
Author

panjiesw commented Apr 8, 2021

Update: found a response for your workaround here: GoogleChrome/workbox#2749 (comment), do you suggest to not enable dynamicStartUrl for now? Since the offline check likely will get improvement in Chrome anyway

@tatethurston
Copy link

tatethurston commented Apr 8, 2021

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 c641621

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

@shadowwalker
Copy link
Owner

Try version 5.2.4 and config this option:

dynamicStartUrlRedirect: '/login' // recommend to config this for best user experience if your start-url redirects on first load

@panjiesw
Copy link
Author

panjiesw commented Apr 9, 2021

@shadowwalker thanks using dynamicStartUrlRedirect works! But seems like there is console.log statement here

console.log('Created cache start-url: ', has)

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

@shadowwalker
Copy link
Owner

Version 5.2.7 should fix this problem.

@panjiesw
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants