Implement neon authentication middleware and refactor session management - #7
Merged
Conversation
Split monolithic auth module into separate client and server boundaries Add catch-all auth api route handler Initialize neon database and cloudflare r2 infrastructure clients Update root middleware route matching patterns Add @neondatabase/auth beta dependency
…e-based session - Replace @neondatabase/neon-js client with @neondatabase/auth/next createAuthClient - Use authClient.useSession() hook in providers for reactive session sync - Rewrite services/user.ts to use authClient for OTP and OAuth - Rename middleware.ts to proxy.ts (Next.js 16 convention) with auth.middleware() - Remove localStorage token management from api-client.ts - Session now stored in HTTP-only cookies, enabling server-side middleware auth
Remove deprecated client-side neon auth client implementation Delete unused proxy auth handler Standardise neon auth environment variable names Add explicit session validation flow for protected routes
- Move auth check to middlewares/auth.ts as standalone middleware - Use middleware chain pattern in middleware.ts for extensibility - Check session via auth.getSession() and redirect unauthenticated users
Correct authentication environment variable names in both English and Chinese documentation. Replace deprecated configuration keys with the new required NEON_AUTH_BASE_URL and NEON_AUTH_COOKIE_SECRET values for project setup instructions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.