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
Percy
Percy2y ago
Project ID: 977d5267-8c30-4ad4-b028-25ad1a926f41
romandev
romandevOP2y ago
977d5267-8c30-4ad4-b028-25ad1a926f41
romandev
romandevOP2y ago
as you can see, the program was deployed successfully
romandev
romandevOP2y ago
I didn’t found solutions yet
luna
luna2y ago
are you using process.env.PORT or is 8000 hardcoded?
romandev
romandevOP2y ago
Im using rocket (rust framework) And PORT its an env var
luna
luna2y ago
Railway Docs
Fixing Common Errors | Railway Docs
Documentation for Railway
romandev
romandevOP2y ago
the api doesn't return an error explicitly
romandev
romandevOP2y ago
i setted the env variables
romandev
romandevOP2y ago
and all run perfect, but for some reason, the GET method doesn't work properly
luna
luna2y ago
the port shouldnt need to be set, it should be set by railway. you just use the PORT
romandev
romandevOP2y ago
if i remove the PORT, rocket doesn't know how to respond
luna
luna2y ago
I 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.
romandev
romandevOP2y ago
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?
luna
luna2y ago
your app should be listening to http on the PORT and railway will handle all the SSL
romandev
romandevOP2y ago
my app is listening on PORT already
luna
luna2y ago
its unlikely a CORS issue.
romandev
romandevOP2y ago
here's the logs
romandev
romandevOP2y ago
the first log its just a debug log for other reasons
Brody
Brody2y ago
do you have a link to your repo you could share?
romandev
romandevOP2y ago
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.
romandev
romandevOP2y ago
actually in my .env file, i didn't set any PORT or HOST
Brody
Brody2y ago
I like the readme
romandev
romandevOP2y ago
Thanks 🤣
Brody
Brody2y ago
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)
romandev
romandevOP2y ago
romandev
romandevOP2y ago
the strange issue is here
romandev
romandevOP2y ago
because instead of return 404, returns 400
Brody
Brody2y ago
I know
romandev
romandevOP2y ago
but locally, returns 200 and the json
Brody
Brody2y ago
where is your mongo database hosted
romandev
romandevOP2y ago
in sao paulo
Brody
Brody2y ago
by who
romandev
romandevOP2y ago
in a M0 cluster aws
Brody
Brody2y ago
ah not railway
romandev
romandevOP2y ago
yeah
Brody
Brody2y ago
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
romandev
romandevOP2y ago
hmmmm the uri string is correct too so, for some reason the db cannot execute find_one
Brody
Brody2y ago
how about actually printing the error instead of throwing it away?
romandev
romandevOP2y ago
that's exactly what im doing rn
romandev
romandevOP2y ago
romandev
romandevOP2y ago
romandev
romandevOP2y ago
lmao that's its i think no, isn't work
Brody
Brody2y ago
you'll get to the bottom of this
romandev
romandevOP2y ago
i think i got the solution i passed bad the username 💀 @Brody
Brody
Brody2y ago
yes?
Want results from more Discord servers?
Add your server