Next.js Discord

Discord Forum

SSR

Answered
TK-ed posted this in #help-forum
Open in Discord
How can i use the ssr feature by calling an api thats written inside of the app folder?? I keep trying with different ways but im getting 404 not found!!
Answered by aardani
ur route.js is wrong
View full answer

64 Replies

this is the component which is calling the api
this is the api im calling but when i call this i get 404 error
idk if im specifying the route wrong
European sprat
i noticed in your first screenshot you had "use server" at the top of the API route and that is not correct, it should be removed
or maybe theres a folder structure im missing or smtg like that
European sprat
looks like you also have a pages directory inside an app directory, i'm not sure if that will create issues but i'd avoid that if possible
getData.js should be named route.js
European sprat
if you're using the app router, read the app router docs for route handlers and routing in general
but guides were using the pages folder thingy so tried that too but did not work
i tried those but they did not work bro @European sprat
provide more information if it "did not work bro"
European sprat
at this point i'd say create a minimal reproduction
@aardani provide more information if it "did not work bro"
i get the route not found
it worked if i used frontend routing while when i try the backend work it doesnt
404 not found is the error i find
can you share updated code
like github link or screenshare??
havent pushed it to github
Minimal reproduction code, anything that would reproduce your issue without irrelevant stuff
@aardani Minimal reproduction code, anything that would reproduce your issue without irrelevant stuff
what is the error
literally "404 not found is the error i find"?
hold on
try deleting .next folder
and rerun server
lemme check
same error
but localhost:3000 works?
yeah just submit a minimal reproduction repository, github or codesandbox
can you try accessing localhost:3000/api directly in the browser
@aardani but localhost:3000 works?
yea
@aardani can you try accessing localhost:3000/api directly in the browser
yes i got this from the browsers console
oh
lol
ur route.js is wrong
Answer
@aardani ur route.js is wrong
oh
this should get you started
i was just tryna pass some dummy data until i connect it to a db
i know
but its not recognized as a Next.js endpoint right now
oh ohhh
since its not the proper format
pay attention to the return type and the parameter
you can still return dummy data
i hope it helps
@aardani i hope it helps
ah man i kinda understood where im wrong and a thousand thanks for you
no worries
@aardani no worries
are you familiar with nextjs?
are you saying im a scam?
lmfao no i could learn a few things from you xD
Peterbald
Next.js expert is here
I can help you
@Peterbald Next.js expert is here
im tryna do my first fullstack project using next,js for a government hackathon.. should i go next.js fullstack or stick with next+fastapi or next+express(since im familiar with this)
@TK-ed im tryna do my first fullstack project using next,js for a government hackathon.. should i go next.js fullstack or stick with next+fastapi or next+express(since im familiar with this)
Peterbald
That is interesting. So are you currently looking for a Next.js + express or Next.js + fastapi developer?
Peterbald
I am familiar with new Next.js version
@Peterbald I am familiar with new Next.js version
can i dm you??
Peterbald
Yeah~