#api 404

43 messages · Page 1 of 1 (latest)

halcyon kite
#

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

lunar turret
#

hey, a minimal reproduction in stackblitz or code sandbox would be nice to be able to debug the issue

halcyon kite
#

will try

halcyon kite
#

can i give you access to my github repo?

#

this thing has a lot of dependencies

lunar turret
#

if it's public yes 🙂

unborn plover
#

what's inside your start command?

halcyon kite
halcyon kite
halcyon kite
halcyon kite
#

@winter herald sorry to summon you but can you give me a hand here?

warm helm
halcyon kite
#

yeah i'm new to this and i don't know how to do that xd

warm helm
halcyon kite
winter herald
#

When using SSG, you only have static files, no running server ~> no API

halcyon kite
#

thank you so much mate

halcyon kite
#

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

winter herald
winter herald
nova sundial
#

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).

halcyon kite
#

ok, will try now only using build

halcyon kite
winter herald
halcyon kite
#

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