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