Skip to content

Commit 974326e

Browse files
fix(next-auth): allow users to use the application offline (#115)
**Why:** When a user is offline and runs an application, he will always be unauthorized. For my app, I temporarily changed the cache config and now suggesting the same changes. **What changed:** - Update the list of URLs excluded from caching by making it more specific: `/api/auth/` => `/api/auth/callback/`. - Google Auth is tested in _Chrome 119 arm64 for macOS_, _Safari 17.0 for macOS_ ans _Safari for iOS 17.1.1_. - Opening pages offline works fine, tested in the same browsers. - Tested logging out when the user is online and the token is not valid.
1 parent d074711 commit 974326e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/honest-dots-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ducanh2912/next-pwa": patch
3+
---
4+
5+
fix(next-auth): allow users to use the application offline

packages/next-pwa/src/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const defaultCache: RuntimeCaching[] = [
141141
// Exclude /api/auth/callback/* to fix OAuth workflow in Safari without having an impact on other environments
142142
// The above route is the default for next-auth, you may need to change it if your OAuth workflow has a different callback route
143143
// Issue: https://github.com/shadowwalker/next-pwa/issues/131#issuecomment-821894809
144-
if (!sameOrigin || pathname.startsWith("/api/auth/")) {
144+
if (!sameOrigin || pathname.startsWith("/api/auth/callback")) {
145145
return false;
146146
}
147147

0 commit comments

Comments
 (0)