Next.js Discord

Discord Forum

Hitting API route returns no data on App Router

Unanswered
Gharial posted this in #help-forum
Open in Discord
GharialOP
I have an API endpoint app/api/chat/route.ts

export async function GET() {
    return Response.json({ data: 'Test!' })
}


When I hit the API endpoint it returns only a blank page. I'm trying to set up the AI Streaming examples but I can't actually even hit the API endpoint?

33 Replies

GharialOP
I currently use the pages router but I want to set up the AI response streaming which seems to need the app router. Maybe I havent set up the folder structure correctly?
no it looks correct
can u go on the page and clear ur cache?
if u are using chrome hold on the reload button while u have devtools open
and in the menu select the last option for full page reload
GharialOP
Thanks for replying btw!
I'm just using Insomnia to make the API request
I'd exect a response like this usually
Using version: "next": "14.2.14",
@Gharial I'm just using Insomnia to make the API request
show me a screenshot of the headers
GharialOP
uhm
those are the request headers
i mean the reponse
here it shows 13
GharialOP
Oh sorry
It looks like its being funneled through to the frontend
^^ thats the app apirequest vs this one which is the pages api request
Original message was deleted
this one is /chat ?
GharialOP
First one with the Set-Cookie is the /chat
@Gharial First one with the Set-Cookie is the /chat
why does it return Set-Cookie?
is it from the middleware?
GharialOP
Ugh, I just shut down my server and started it again and it's started working 😦
@Gharial Click to see attachment
nice 👍
GharialOP
Apologies, think it's just late now, been stuck on this for 2 hrs lol
thanks for your support, much appreciated!
:)
@Gharial thanks for your support, much appreciated!
you can mark this post as resolved
GharialOP
Will do, thanks 🙂