N
Nuxt5mo ago
ZaKk

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
Sam  K
Sam K5mo ago
hey, a minimal reproduction in stackblitz or code sandbox would be nice to be able to debug the issue
ZaKk
ZaKkOP5mo ago
will try can i give you access to my github repo? this thing has a lot of dependencies
Sam  K
Sam K5mo ago
if it's public yes 🙂
kue
kue5mo ago
what's inside your start command?
ZaKk
ZaKkOP5mo ago
"start": "nuxt start", no it isn't because it has api passwords
ZaKk
ZaKkOP5mo ago
GitHub
GitHub - renobizarrox/lacsys: laconic repo
laconic repo. Contribute to renobizarrox/lacsys development by creating an account on GitHub.
ZaKk
ZaKkOP5mo ago
@manniL / TheAlexLichter sorry to summon you but can you give me a hand here?
Cue
Cue5mo ago
Shouldn’t commit passwords even in private repos. Use environment variables!
ZaKk
ZaKkOP5mo ago
yeah i'm new to this and i don't know how to do that xd
Cue
Cue5mo ago
Nuxt
.env · Nuxt Directory Structure
A .env file specifies your build/dev-time environment variables.
ZaKk
ZaKkOP5mo ago
thank you
manniL
manniL5mo ago
That is actually intended
manniL
manniL5mo ago
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...
manniL
manniL5mo ago
When using SSG, you only have static files, no running server ~> no API
ZaKk
ZaKkOP5mo ago
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
ZaKk
ZaKkOP5mo ago
this is how it looks on my computer
No description
ZaKk
ZaKkOP5mo ago
and this is how it looks on my server
No description
ZaKk
ZaKkOP5mo ago
server responses
No description
ZaKk
ZaKkOP5mo ago
the only difference is that in local it runs on macOS sonoma and in server runs on docker
manniL
manniL5mo ago
unrelated: don't use GET for a login please 😄 hard to tell without code/info/....
Single
Single5mo ago
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).
ZaKk
ZaKkOP5mo ago
ok, will try now only using build what should i use then?
manniL
manniL5mo ago
POST
ZaKk
ZaKkOP5mo ago
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
ZaKk
ZaKkOP5mo ago
GitHub
GitHub - renobizarrox/lacsys: laconic repo
laconic repo. Contribute to renobizarrox/lacsys development by creating an account on GitHub.
ZaKk
ZaKkOP5mo ago
nevermind, looks like it was my cache
Want results from more Discord servers?
Add your server