chore(next): upgrade to Next.js 16.1.4 + React 19.2.3 — codemod, API fixes, and proxy migration#66
chore(next): upgrade to Next.js 16.1.4 + React 19.2.3 — codemod, API fixes, and proxy migration#66umanda wants to merge 5 commits intomichaelshimeles:mainfrom
Conversation
…at with better-auth)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63cc45624f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import { getSessionCookie } from "better-auth/cookies"; | ||
|
|
||
| export async function middleware(request: NextRequest) { | ||
| export async function proxy(request: NextRequest) { |
There was a problem hiding this comment.
Keep Next middleware discoverable
Next.js only runs middleware when it finds a root middleware.ts/src/middleware.ts and an exported middleware function; renaming the file to proxy.ts and the export to proxy means this logic will never execute in a standard Next.js build. That removes the redirect guard for /sign-in, /sign-up, and /dashboard (logged-in users can see auth pages and unauthenticated requests won’t be intercepted until page-level checks run). If you’re not wiring a new proxy entrypoint elsewhere, this should stay as middleware.ts with an exported middleware function.
Useful? React with 👍 / 👎.
Greptile OverviewGreptile SummaryMigrated the app from Next.js 15 to 16.1.4 and React 18 to 19.2.3, applying both automated codemod changes and manual runtime compatibility fixes. Key changes:
All auth integration points have been systematically updated to handle the new Next.js 16 server runtime behavior. The middleware logic remains unchanged, only the export pattern was updated. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Proxy as proxy.ts
participant Route as API Route
participant Auth as better-auth
participant DB as Database
Note over Proxy: Next.js 16 middleware pattern
Client->>Proxy: Request to protected route
Proxy->>Proxy: Validate session cookie
alt No session
Proxy->>Client: Redirect to sign-in
else Valid
Proxy->>Route: Forward request
end
Note over Route,Auth: Updated auth integration
Route->>Route: Convert Headers to plain object
Route->>Auth: Call getSession with headers object
Auth->>DB: Validate session
DB->>Auth: Session data
Auth->>Route: Return session
Route->>Client: Send response
|
|
I'm rebuilding the template to a new version really soon, will be changing the tech stack so won't be merging this |
Summary: Upgrade the app to Next.js 16.1.4 and React 19.2.3 using the official Next codemod, apply required runtime fixes, and migrate middleware to the new proxy pattern so the app builds and runs under Next 16.
Why: Next 16 brings new server runtime behavior (Headers handling, route collection), codemod automates many changes but some call-sites and third-party integrations needed manual fixes to match the new context shapes.
Key changes:
Files/areas touched (high level):