Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/api/auth/atproto.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default defineEventHandler(async event => {
scope,
prompt: create ? 'create' : undefined,
})
return sendRedirect(event, redirectUrl.toString())
return redirectUrl
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Returning redirectUrl breaks the OAuth authorization flow.

OAuth requires the browser to be redirected to the authorization server. Returning the URL object directly causes it to be serialised as JSON, which prevents the redirect from occurring and breaks authentication.

If this is intentional for debugging the redirect URL in Vercel, consider logging the URL before performing the redirect instead:

🐛 Suggested fix to preserve OAuth flow whilst enabling debugging
       const redirectUrl = await atclient.authorize(handle, {
         scope,
         prompt: create ? 'create' : undefined,
       })
-      return redirectUrl
+      console.log('[OAuth Debug] Redirect URL:', redirectUrl.toString())
+      return sendRedirect(event, redirectUrl.toString())
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return redirectUrl
console.log('[OAuth Debug] Redirect URL:', redirectUrl.toString())
return sendRedirect(event, redirectUrl.toString())

} catch (error) {
const message = error instanceof Error ? error.message : 'Authentication failed.'

Expand Down
Loading