#Api getting endpoint

66 messages · Page 1 of 1 (latest)

sleek sparrow
#

Hi, im building an api and all is well for now but if i make GET locally (127.0.0.1:8000/gif/1) the server responds correctly, but if i do the same thing in the domain of railway (https://gen-t-api.up.railway.app/gif/1) this returns a custom error i setted (400 Bad Request) , how can i fix it?

full tangleBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

wise lightBOT
#

Project ID: 977d5267-8c30-4ad4-b028-25ad1a926f41

sleek sparrow
#

977d5267-8c30-4ad4-b028-25ad1a926f41

#

as you can see, the program was deployed successfully

sleek sparrow
left wasp
#

are you using process.env.PORT or is 8000 hardcoded?

sleek sparrow
#

Im using rocket (rust framework)

#

And PORT its an env var

left wasp
sleek sparrow
#

the api doesn't return an error explicitly

#

i setted the env variables

#

and all run perfect, but for some reason, the GET method doesn't work properly

left wasp
#

the port shouldnt need to be set, it should be set by railway.

#

you just use the PORT

sleek sparrow
#

if i remove the PORT, rocket doesn't know how to respond

left wasp
sleek sparrow
#

hmmm

#

doesn't work

#

the PORT env setted by railway is ok

#

but for some reason, if i adjust the ROCKET_ADDRESS to 0.0.0.0 (will use 127.0.0.1 instead) the proyect is builded correctly but doesn't respond

#

could it because the url that provides railway contains https and in rocket, its setted to http ?

#

@tall sorrel srry the ping but you know something about this?

#

maybe i should add CORS?

left wasp
#

your app should be listening to http on the PORT and railway will handle all the SSL

sleek sparrow
left wasp
#

its unlikely a CORS issue.

sleek sparrow
#

here's the logs

#

the first log its just a debug log for other reasons

tall sorrel
#

do you have a link to your repo you could share?

sleek sparrow
#

actually in my .env file, i didn't set any PORT or HOST

tall sorrel
#

I like the readme

sleek sparrow
#

Thanks 🤣

tall sorrel
#

once those two variables are back in tact, show me a screenshot of all your service variables

#

(I do know what's wrong, but there are steps we have to take to get your app in working condition)

sleek sparrow
#

the strange issue is here

#

because instead of return 404, returns 400

tall sorrel
#

I know

sleek sparrow
#

but locally, returns 200 and the json

tall sorrel
#

where is your mongo database hosted

sleek sparrow
#

in sao paulo

tall sorrel
#

by who

sleek sparrow
#

in a M0 cluster

sleek sparrow
tall sorrel
#

ah not railway

sleek sparrow
#

yeah

tall sorrel
#

okay well then I will leave that up to you, your issues lies with the connection to your database

#

your api is running and accepting requests just fine

sleek sparrow
#

hmmmm

#

the uri string is correct too

#

so, for some reason the db cannot execute find_one

tall sorrel
sleek sparrow
#

lmao

#

that's its i think

#

no, isn't work

tall sorrel
#

you'll get to the bottom of this

sleek sparrow
#

i think i got the solution

#

i passed bad the username 💀

#

@tall sorrel

tall sorrel
#

yes?