Api getting endpoint
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?46 Replies
Project ID:
977d5267-8c30-4ad4-b028-25ad1a926f41
977d5267-8c30-4ad4-b028-25ad1a926f41
as you can see, the program was deployed successfully
I didn’t found solutions yet
are you using
process.env.PORT
or is 8000
hardcoded?Im using rocket (rust framework)
And
PORT
its an env
varanything on here stick out? https://docs.railway.app/troubleshoot/fixing-common-errors
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 properlythe port shouldnt need to be set, it should be set by railway.
you just use the PORT
if i remove the
PORT
, rocket doesn't know how to respondI wonder if this is the same as https://canary.discord.com/channels/713503345364697088/1110912233980051508
all of my apps just listen to PORT and they work out of the box, no needing to set it myself.
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
?
@Brody srry the ping but you know something about this?
maybe i should add CORS
?your app should be listening to http on the
PORT
and railway will handle all the SSLmy app is listening on
PORT
alreadyits unlikely a CORS issue.
here's the logs
the first log its just a debug log for other reasons
do you have a link to your repo you could share?
GitHub
GitHub - ChirujanoCodding/gen-t-api: Api for Generacion-T for futur...
Api for Generacion-T for future excercises. . Contribute to ChirujanoCodding/gen-t-api development by creating an account on GitHub.
actually in my
.env
file, i didn't set any PORT
or HOST
I like the readme
Thanks 🤣
for a rocket app, this is correct. whatever you have changed in your variables since this, put this back please
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)
the strange issue is here
because instead of return
404
, returns 400
I know
but locally, returns
200
and the jsonwhere is your mongo database hosted
in sao paulo
by who
in a M0 cluster
aws
ah not railway
yeah
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
hmmmm
the
uri
string is correct too
so, for some reason the db cannot execute find_one
how about actually printing the error instead of throwing it away?
that's exactly what im doing rn
lmao
that's its i think
no, isn't work
you'll get to the bottom of this
i think i got the solution
i passed bad the username 💀
@Brody
yes?