You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, in the last Next.js version apparently new rules were added, and you can no longer return undefined, the route API expects you to return "Response | Promise"
As the error mentions, you have an undefined in your GET route.
Just add a response in this last catch and that's it 👍
exportasyncfunctionGET(req: Request,res: Response){try{constcookieStore=cookies()consttoken=cookieStore.get(SEARCHED)constposts=JSON.parse(token!.value)returnNextResponse.json(posts)}catch(error){returnNextResponse.json({error: 'Ouch, GET is not working my friend'},{status: 500},)}}
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
Link to the code that reproduces this issue
https://github.com/Revaycolizer/minimal-repo/tree/main/app/api
To Reproduce
Current vs. Expected behavior
Expected to return data but instead it throws an error stating that Promise<NextResponse | undefined>" is not a valid GET return type:
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router
Additional context
I am deploying my application in vercel
The text was updated successfully, but these errors were encountered: