Skip to content

fix: use request headers for landing session - #42

Closed
prathamdby wants to merge 1 commit into
masterfrom
codex/locate-and-fix-critical-bug
Closed

fix: use request headers for landing session#42
prathamdby wants to merge 1 commit into
masterfrom
codex/locate-and-fix-critical-bug

Conversation

@prathamdby

Copy link
Copy Markdown
Owner

No description provided.

@prathamdby

Copy link
Copy Markdown
Owner Author

/review

1 similar comment
@prathamdby

Copy link
Copy Markdown
Owner Author

/review

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

GitHub PR Review

P0 Critical API misuse in Next.js App Router. The headers() function returns a Headers object directly, not a Promise. This will cause a runtime error.

// Current (incorrect)
headers: await headers(),

// Correct
headers: headers(),

P1 Missing import validation. The headers() function from next/headers can only be called in Server Components or Route Handlers. Verify this is being used in the correct context.

P2 Consider adding type safety for the session response to ensure the user property exists before redirecting.

github run

@prathamdby

Copy link
Copy Markdown
Owner Author

/review

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

GitHub PR Review

P0 Critical API misuse in Next.js App Router. The headers() function is async in Next.js 15+ and returns a Promise. This will cause a runtime error.

// Current (incorrect)
headers: await headers(),

// Correct
headers: headers(),

P1 The headers() function from next/headers can only be called in Server Components. Verify this file is being used in the correct Server Component context.

P2 Consider adding type safety for the session response to ensure the user property exists before redirecting.

github run

@prathamdby

Copy link
Copy Markdown
Owner Author

/review

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

GitHub PR Review

File: app/page.tsx
Lines: 59
Severity: P0

Code:

headers: await headers(),

Issue: Critical runtime error. The headers() function in Next.js 15+ is async and returns a Promise, but you're already awaiting it correctly. However, the auth API likely expects a Headers object directly, not a Promise wrapper.

Fix:

headers: headers(),

File: app/page.tsx
Lines: 56-60
Severity: P2

Code:

const session = await auth.api.getSession({
  headers: headers(),
});

if (session?.user) {

Issue: Missing type safety for session response. The optional chaining on session?.user suggests the session might be null/undefined, but there's no explicit type checking.

Fix:

const session = await auth.api.getSession({
  headers: headers(),
});

if (session?.user?.id) {

github run

@prathamdby

Copy link
Copy Markdown
Owner Author

/review

@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

GitHub PR Review

app/page.tsx (line 60)

Severity: P0

What: Incorrect usage of async headers() function - double awaiting
Why: The Next.js 16 docs confirm headers() returns a Promise that should be awaited once, but the code is using await headers() which will cause a runtime error since you're awaiting a Promise that returns a Headers object, not another Promise.


app/page.tsx (lines 17, 60)

Severity: P1

What: API usage mismatch between import and implementation
Why: The code imports headers from next/headers and uses await headers(), but the auth API expects a Headers object directly, not a Promise. This violates the Next.js App Router pattern shown in the docs where headers() should be awaited and the result passed directly.

github run

@prathamdby prathamdby closed this Feb 4, 2026
@prathamdby
prathamdby deleted the codex/locate-and-fix-critical-bug branch February 4, 2026 10:32
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.

1 participant