shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.89k stars 325 forks source link

Access token expires after <24h using nextjs-auth0 #310

Closed albehrens closed 2 years ago

albehrens commented 2 years ago

I have an application (https://taskli.st) using next-pwa. I am using Auth0 for authentication (https://github.com/auth0/nextjs-auth0). Expiration date for both the api as well as the application tokens is set to 30 days. However whenever I open my PWA the next day I have to log in again. I do not have to log in when I am using the web application. I am assuming that this is happening because nextjs-auth0 fails to set a cookie properly when opened as PWA, because Auth0 uses that cookie to refresh access tokens automatically. Do you know how I can fix my issue?

shadowwalker commented 2 years ago

Have you tried to tune runtime caching config for your auth routes? Below is the opinionated default: https://github.com/shadowwalker/next-pwa/blob/d34500472fac829584e95a8f3a7855d67e987cb7/cache.js#L133-L136

albehrens commented 2 years ago

I solved it. Turned out that this was not a next-pwa problem at all. I just needed to pass the offline_access scope to auth0 when setting up the provider.