Old project stopped working after re-deploying

I had a running project that go destroyed to to resource outage! so i just brought the hobby plan! and redeployed the project! But now it is failing ! the error i am getting errors maybe because of env variables not being recognized properly!
requests.js:17
GET http://localhost:5000/v1/launches net::ERR_BLOCKED_BY_CLIENT
requests.js:10
GET http://localhost:5000/v1/planets net::ERR_BLOCKED_BY_CLIENT
requests.js:17
GET http://localhost:5000/v1/launches net::ERR_BLOCKED_BY_CLIENT
requests.js:10
GET http://localhost:5000/v1/planets net::ERR_BLOCKED_BY_CLIENT
my request .js part which deciding the url:
const API_URL =
process.env.REACT_APP_ENV === "prod"
? "https://the-nasa-project-production.up.railway.app/v1"
: `http://localhost:${process.env.REACT_APP_SERVER_PORT}/v1`;
const API_URL =
process.env.REACT_APP_ENV === "prod"
? "https://the-nasa-project-production.up.railway.app/v1"
: `http://localhost:${process.env.REACT_APP_SERVER_PORT}/v1`;
so in prod is should get the url https://the-nasa-project-production.up.railway.app/v1 not the
localhost
localhost
url that it is trying to sent the request to ! But looks like inspite of my env the project is not working : But the app is working:
NASA Mission Control
NASA Mission Control Dashboard
No description
No description
57 Replies
Percy
Percy8mo ago
Project ID: bc1834fc-5106-4839-bf78-b34a80a5af88
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
bc1834fc-5106-4839-bf78-b34a80a5af88
Brody
Brody8mo ago
How old are we talking?
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
well according to deployment logs it is 6 months but i didn't needed that so i ran out of free resources and railway blocked it but i need that projeect to up! so i just brought the plan and click the redeployed button! no changes was made! but looks like it's having issue in recognizing env! by no change i meant no change was made to the lastly deployed codebase
Brody
Brody8mo ago
do you build it with nixpacks or a dockerfile?
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
its showing nixpacks! actually when i built this project node was in v14 ! so yeah pretty old project! so i am even scared to touch it because renwing it up will take me a lot effort in terms of depedncy resolving and version patchings and lot of things even could break! and it doesnt even looks like it a problem to my code base! just the problem here is maybe the app is not recgnizing env! so i can introduce a log just to prove you that! but i don't think i need it
Adam
Adam8mo ago
What part of your code checks the env variable? Nothing on Railway’s side has changed how env variables work. Add print statements to your code to debug if it’s retrieving the env variable correctly and we’ll go from there
Brody
Brody8mo ago
does it need node 14? because nixpacks will not build with node 14 (unless you pin to an old version of nixpacks)
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
so may be thats a node platform issue that deploying the code wth a non node version? guys it suddenlt started working now ! XD
Brody
Brody8mo ago
can you console.log an environment variable just for sure like Adam asked, and in the mean also send your latest build logs - https://bookmarklets.up.railway.app/log-downloader/
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
that means maybe it was some platform issues
Brody
Brody8mo ago
nothing is reported, so please let's not jump to such conclusions
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
No description
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
earlier this was showing empty
Brody
Brody8mo ago
I'd still be very interested in seeing your build logs, would you mind sending them anyway?
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
how to download the logs
Brody
Brody8mo ago
use this bookmarklet
Brody
Brody8mo ago
please use the bookmarklet
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
is it a button?
Brody
Brody8mo ago
follow the 3 steps on that bookmarklets page
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
can u give the url of the page?
Brody
Brody8mo ago
right here
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
used the booklet script'
Brody
Brody8mo ago
that is the deployment logs for your API, I would like the build logs for your frontend
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
oh there i no build logs for my frontend ! because i am including a builded react app and serving the builded react project using express
Brody
Brody8mo ago
okay I see can I still get those build logs?
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
so like if i needed to log i need rebuild the front and include the new front build directory ! it's a little bit manual process but yeah i was a kid that time and a youtube video showed that so i foolwed it! terminal logs of the front build?
Brody
Brody8mo ago
please send your build logs the same way you sent the deployment logs
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
instead of some docker logs there is nothing but still as you wanted here it is!
Brody
Brody8mo ago
that's exactly what I wanted well there's your reason for the missing environment variables, you aren't having railway build the frontend!
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
but earlier it was working and not it is working to! and as i said i don't need to ! because my frontend is like a js file search for a env! so in that case it becomes a part of your server project! because the frontend is nothing but a route of my backend!
Brody
Brody8mo ago
I promise you, this will break again in the future if you don't set this up properly
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
so according to you env varibales are a build time thing comapred to a runtime thing?
Brody
Brody8mo ago
for static websites, yes
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
hmmm! your comment makes sense in a way! then question comes that how it was getting the env earlier and now who supplied it? if it is not a runtime stuff?
Brody
Brody8mo ago
you, probably a local .env file
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
https://github.com/ToxicalNoob3062/THE-NASA-PROJECT/tree/master well i think railway is fetching my latest deployment as i can see of github! and in my are eyes i can see any .env file in my repo
GitHub
GitHub - ToxicalNoob3062/THE-NASA-PROJECT: A node js project to que...
A node js project to query about future rocket launches and start and stop launches from options! - ToxicalNoob3062/THE-NASA-PROJECT
Brody
Brody8mo ago
i didnt expect there to be a .env file in your repo, i never said that
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
REACT_APP_ENV=dev REACT_APP_SERVER_PORT=5000 REACT_APP_PORT=5000 PORT=5000 oh my bad but my server had a .env file in my local repo with this variabbles but these never get included in the cloud repo! so then what are you trying to say?
Brody
Brody8mo ago
you built the frontend locally!
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
yeah but my frontend repo soesnt have any env reference ! so during build time how will it get it?
Brody
Brody8mo ago
yes it does, bruh
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
https://github.com/ToxicalNoob3062/THE-NASA-PROJECT/tree/master/client this is the same client repo that i am seeing now in my dev env too all the files are synced ! and i am using the build command of pakcage.json which is also doesnt giving any env as it arguements!
GitHub
THE-NASA-PROJECT/client at master · ToxicalNoob3062/THE-NASA-PROJECT
A node js project to query about future rocket launches and start and stop launches from options! - ToxicalNoob3062/THE-NASA-PROJECT
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
so your claim seems to be a great magic to me! that for fisrtdeployment it was not working because it didnt get the env due to the build process ! and when i retried the build env wa sosmehow go some magic and it started working gaain
Brody
Brody8mo ago
i know you wrote this code a long time ago, but still, your frontend does use environment variables https://github.com/ToxicalNoob3062/THE-NASA-PROJECT/blob/master/client/src/hooks/requests.js#L5
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
see there is 2 cases ! if i really supplied the env during build then even if i remove the env from the railway app it should work the same! but i can show you now a practically demo that if i remove the react app env my deployment will stop working again do you want to test?
Brody
Brody8mo ago
of course it will stop working, you arent having railway built the frontend
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
what are you saying?? if the env for static website is a build thing then my app should work even after i remove the runtime variable because runtime varibales are injected to the containe rby railway isn't it
Brody
Brody8mo ago
we are going in circles here
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
because youare not clear in what you say! build time things: the things which are decided in built time ! so if the react env is decided in built time it will store the env variable at that moment isn;t it? do you agree that?
Brody
Brody8mo ago
ive already explained everything, im sorry to hear that you where not able to understand, i would recommend becoming familiar with the technologies you are using
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
you was jsut wrong in this one reply and right in all other replies! everything is clear now! you were right that react supplies in build time! and so even if i change the value of the env or even delete it it's not affecting my application! here i just changed the env as i was saying that changing the env in railway will make my app stop working! and you replied that it will defintely stop ! that was the clash! you should have replied , "nope it will work as same as it did earlier!"
No description
Brody
Brody8mo ago
you have significantly misunderstood almost everything i have said
Rahat Bin Taleb
Rahat Bin TalebOP8mo ago
anyways thanks for your patience! 🙂
Want results from more Discord servers?
Add your server