Getting 500 errors suddenly whenever redirecting to /api/auth/login on nextjs 14+

Not sure what could have caused this - all works well on localhost but blows up once deployed. My codebase has not changed besides integrating Stripe. Any hints on how to debug this?
4 Replies
sassydinosaur
sassydinosaurOP3d ago
The error I see in logs is
ERROR ⨯ Error: No response is returned from route handler. Ensure you return a `Response` or a `NextResponse` in all branches of your handler.
ERROR ⨯ Error: No response is returned from route handler. Ensure you return a `Response` or a `NextResponse` in all branches of your handler.
Ages
Ages3d ago
Hi there, Thanks for providing the error details. To help us diagnose the issue more effectively, could you please let us know: 1. Which version of the Kinde SDK are you currently using? 2. Are you deploying your app to a staging or production environment? This information will help us pinpoint the problem. Thanks
sassydinosaur
sassydinosaurOP3d ago
1.
"@kinde-oss/kinde-auth-nextjs": "^2.5.3"
"@kinde-oss/kinde-auth-nextjs": "^2.5.3"
2. deploying to AWS via SST. Everything works fine on localhost. This is the error on a bare bones implementation
TypeError: Cannot read properties of undefined (reading 'kindeAuth')
TypeError: Cannot read properties of undefined (reading 'kindeAuth')
Ages
Ages2d ago
Hi there, Thanks for sharing the details. To help us further, could you please provide screenshots of your configuration settings from both your local environment and your AWS (SST) deployment? Also, are you using a custom domain in your deployment? In the meantime, as a temporary workaround, you might try wrapping the call to the auth handler in a try/catch block to ensure a response is always returned. For example:
import { NextResponse } from 'next/server'
import { kindeAuth } from '@kinde-oss/kinde-auth-nextjs'

export async function GET(request) {
try {
const response = await kindeAuth(/* your configuration object */)(request)
if (!response) {
console.error('kindeAuth did not return a response')
return NextResponse.error()
}
return response
} catch (error) {
console.error('Error in /api/auth/login:', error)
return NextResponse.error()
}
}
import { NextResponse } from 'next/server'
import { kindeAuth } from '@kinde-oss/kinde-auth-nextjs'

export async function GET(request) {
try {
const response = await kindeAuth(/* your configuration object */)(request)
if (!response) {
console.error('kindeAuth did not return a response')
return NextResponse.error()
}
return response
} catch (error) {
console.error('Error in /api/auth/login:', error)
return NextResponse.error()
}
}
This can help catch errors and ensure that a valid response is returned even if something goes wrong. Once we see your configuration screenshots and learn more about your setup (including whether you’re using a custom domain), we can provide more targeted guidance.

Did you find this page helpful?