Old project stopped working after re-deploying

rahat3062FREE

a year ago

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

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`;

so in prod is should get the url https://the-nasa-project-production.up.railway.app/v1 not the 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:

0 Replies

rahat3062FREE

a year ago

bc1834fc-5106-4839-bf78-b34a80a5af88


a year ago

How old are we talking?


rahat3062FREE

a year ago

well according to deployment logs it is 6 months


rahat3062FREE

a year ago

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!


rahat3062FREE

a year ago

by no change i meant no change was made to the lastly deployed codebase


a year ago

do you build it with nixpacks or a dockerfile?


rahat3062FREE

a year 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!


rahat3062FREE

a year ago

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


a year 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


a year ago

does it need node 14? because nixpacks will not build with node 14 (unless you pin to an old version of nixpacks)


rahat3062FREE

a year ago

so may be thats a node platform issue that deploying the code wth a non node version?


rahat3062FREE

a year ago

guys it suddenlt started working now ! XD


a year ago

can you console.log an environment variable just for sure like Adam asked, and in the mean also send your latest build logs -


rahat3062FREE

a year ago

that means maybe it was some platform issues


a year ago

nothing is reported, so please let's not jump to such conclusions


rahat3062FREE

a year ago

1228018101874983000


rahat3062FREE

a year ago

earlier this was showing empty


a year ago

I'd still be very interested in seeing your build logs, would you mind sending them anyway?


rahat3062FREE

a year ago

how to download the logs


a year ago

use this bookmarklet


rahat3062FREE

a year ago


a year ago

please use the bookmarklet


rahat3062FREE

a year ago

is it a button?


a year ago

follow the 3 steps on that bookmarklets page


rahat3062FREE

a year ago

can u give the url of the page?


a year ago

right here


rahat3062FREE

a year ago


rahat3062FREE

a year ago

used the booklet script'


a year ago

that is the deployment logs for your API, I would like the build logs for your frontend


rahat3062FREE

a year 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


a year ago

okay I see


a year ago

can I still get those build logs?


rahat3062FREE

a year 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!


rahat3062FREE

a year ago

terminal logs of the front build?


a year ago

please send your build logs the same way you sent the deployment logs


rahat3062FREE

a year ago


rahat3062FREE

a year ago

instead of some docker logs there is nothing but still as you wanted here it is!


a year ago

that's exactly what I wanted


a year ago

well there's your reason for the missing environment variables, you aren't having railway build the frontend!


rahat3062FREE

a year 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!


a year ago

I promise you, this will break again in the future if you don't set this up properly


rahat3062FREE

a year ago

so according to you env varibales are a build time thing comapred to a runtime thing?


a year ago

for static websites, yes


rahat3062FREE

a year ago

hmmm! your comment makes sense in a way! then question comes that how it was getting the env earlier and now


rahat3062FREE

a year ago

who supplied it?


rahat3062FREE

a year ago

if it is not a runtime stuff?


a year ago

you, probably a local .env file


rahat3062FREE

a year 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


a year ago

i didnt expect there to be a .env file in your repo, i never said that


rahat3062FREE

a year ago

REACTAPPENV=dev
REACTAPPSERVERPORT=5000 REACTAPP_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?


a year ago

you built the frontend locally!


rahat3062FREE

a year ago

yeah but my frontend repo soesnt have any env reference ! so during build time how will it get it?


a year ago

yes it does, bruh


rahat3062FREE

a year 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!


rahat3062FREE

a year ago

so your claim seems to be a great magic to me!


rahat3062FREE

a year ago

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


a year ago

i know you wrote this code a long time ago, but still, your frontend does use environment variables


rahat3062FREE

a year 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


rahat3062FREE

a year ago

do you want to test?


a year ago

of course it will stop working, you arent having railway built the frontend


rahat3062FREE

a year 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


a year ago

we are going in circles here


rahat3062FREE

a year 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?


a year 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


rahat3062FREE

a year 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!"

1228031846147817500


a year ago

you have significantly misunderstood almost everything i have said


rahat3062FREE

a year ago

anyways thanks for your patience! 🙂