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

fix(next-auth): allow users to use the application offline #115

Merged
merged 2 commits into from
Nov 21, 2023
Merged

fix(next-auth): allow users to use the application offline #115

merged 2 commits into from
Nov 21, 2023

Conversation

vlad-iakovlev
Copy link

@vlad-iakovlev vlad-iakovlev commented Nov 18, 2023

Why this changes is necessary

Users currently face authorization issues when accessing next-pwa based application while being offline.

Suggested changes

  • Update the list of next-auth URLs excluded from caching by making it more specific: /api/auth/ => /api/auth/callback/.

Tested

Providers:

  • Google Auth

Browsers:

  • macOS 14.0 arm64: Chrome 119 and Safari 17.0
  • iOS 17.1.1: Safari in standalone mode

Actions:

  • service worker available
  • app available online and offline
  • auth will be preserved while user offline
  • login works
  • logout works

**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.
Copy link

changeset-bot bot commented Nov 18, 2023

🦋 Changeset detected

Latest commit: ed9c2a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ducanh2912/next-pwa Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@DuCanhGH
Copy link
Owner

Hmm, I wonder why the comment specifies /api/auth/callback/*, yet the code checks for /api/auth/*. Let's just approve the PR then :)

@DuCanhGH DuCanhGH merged commit 974326e into DuCanhGH:master Nov 21, 2023
7 checks passed
@DuCanhGH DuCanhGH mentioned this pull request Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants