api 404
hello guys, i've been strugling with this for a couple of days, i have my project like this:
root
-components
--component1
--component2
-pages
--page1
--page2
-server
--api
---api1
---api2
when i run the project with "yarn dev" it works good, all api calls have a response, when i use "npm run generate" it generate the project with no errors, then when i use "npm start" it starts with no errors but all api requests gets to 404 error, i even added debug messages into my api and they are not shown in console.
using:
nuxt 3.12.4
vue: latest
node: 20.5.1
27 Replies
hey, a minimal reproduction in stackblitz or code sandbox would be nice to be able to debug the issue
will try
can i give you access to my github repo?
this thing has a lot of dependencies
if it's public yes 🙂
what's inside your
start
command?"start": "nuxt start",
no it isn't because it has api passwords
now it is public https://github.com/renobizarrox/lacsys/
GitHub
GitHub - renobizarrox/lacsys: laconic repo
laconic repo. Contribute to renobizarrox/lacsys development by creating an account on GitHub.
@manniL / TheAlexLichter sorry to summon you but can you give me a hand here?
Shouldn’t commit passwords even in private repos. Use environment variables!
yeah i'm new to this and i don't know how to do that xd
thank you
That is actually intended
Alexander Lichter
YouTube
Redirects in Nuxt 3
Redirects are essential for web applications, at least at some point when a migration has to happen or SEO should be improved by having more descriptive URLs.
#nuxt #vue
---
Links and Resources:
🔗 10% Off for vuejs.de Conf with Code LICHTER https://conf.vuejs.de/tickets/?voucher=LICHTER
🔗 Code https://github.com/manniL/alexander-lichter-nuxt...
When using SSG, you only have static files, no running server ~> no API
thank you so much mate
ok this is kind of weird...
in local i make npm run build, then npm run generate and then npm start
it works, it calls the api and the api responds no problem
on my server it doesnt
following the same steps of course
this is how it looks on my computer
and this is how it looks on my server
server responses
the only difference is that in local it runs on macOS sonoma and in server runs on docker
unrelated: don't use GET for a login please 😄
hard to tell without code/info/....
As Alex said, if you
generate
your page. No server is being generated. It is creating a Single Page Application - no backend = no server thus the 404's.
You started the server 'manually' on your local machine thus the API was available, this doesn't count for production. You must use npm run build
instead of generate
and deploy the server (somewhere).ok, will try now only using build
what should i use then?
POST
oh now i get how to make posts
thank you mate
now the server goes up no errors
but something weird is happening...
images are being corrupted somehow
i make a fresh git pull before npm run build
in github the images are ok, i grabbed the image from the server via FTP and it looks fine but after npm run build it gets corrupted
GitHub
GitHub - renobizarrox/lacsys: laconic repo
laconic repo. Contribute to renobizarrox/lacsys development by creating an account on GitHub.
nevermind, looks like it was my cache