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
a year ago
How old are we talking?
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!
a year ago
do you build it with nixpacks or a dockerfile?
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
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)
so may be thats a node platform issue that deploying the code wth a non node version?
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 -
a year ago
nothing is reported, so please let's not jump to such conclusions
a year ago
I'd still be very interested in seeing your build logs, would you mind sending them anyway?
a year ago
use this bookmarklet
a year ago
please use the bookmarklet
a year ago
follow the 3 steps on that bookmarklets page
a year ago
right here
a year ago
that is the deployment logs for your API, I would like the build logs for your frontend
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?
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!
a year ago
please send your build logs the same way you sent the deployment logs
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!
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
so according to you env varibales are a build time thing comapred to a runtime thing?
a year ago
for static websites, yes
hmmm! your comment makes sense in a way! then question comes that how it was getting the env earlier and now
a year ago
you, probably a local .env file
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
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!
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
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!
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
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
a year ago
of course it will stop working, you arent having railway built the frontend
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
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
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!"
a year ago
you have significantly misunderstood almost everything i have said