SSR
Answered
TK-ed posted this in #help-forum
TK-edOP
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!!
64 Replies
this is the api im calling but when i call this i get 404 error
idk if im specifying the route wrong
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
TK-edOP
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 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
TK-edOP
i was using the @latest in create-next-app
European sprat
if you're using the app router, read the app router docs for route handlers and routing in general
TK-edOP
but guides were using the pages folder thingy so tried that too but did not work
TK-edOP
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"
TK-edOP
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
TK-edOP
like github link or screenshare??
havent pushed it to github
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"?
TK-edOP
hold on
try deleting
.next folderand rerun server
TK-edOP
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 can you try accessing localhost:3000/api directly in the browser
TK-edOP
yes i got this from the browsers console
oh
lol
ur route.js is wrong
Answer
this should get you started
TK-edOP
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
TK-edOP
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
TK-edOP
ah man i kinda understood where im wrong and a thousand thanks for you
no worries
@aardani no worries
TK-edOP
are you familiar with nextjs?
are you saying im a scam?
TK-edOP
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
TK-edOP
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
TK-edOP
can i dm you??
Peterbald
Yeah~