Railway error on path
I'm getting this one railway
Path: /
Retry window: 5m0s
Attempt #1 failed with service unavailable. Continuing to retry for 4m59s
Attempt #2 failed with service unavailable. Continuing to retry for 4m58s
Attempt #3 failed with service unavailable. Continuing to retry for 4m56s
Attempt #4 failed with service unavailable. Continuing to retry for 4m52s
Attempt #5 failed with service unavailable. Continuing to retry for 4m44s
Attempt #6 failed with service unavailable. Continuing to retry for 4m28s
Attempt #7 failed with service unavailable. Continuing to retry for 3m58s
Attempt #8 failed with service unavailable. Continuing to retry for 3m28s
Attempt #9 failed with service unavailable. Continuing to retry for 2m58s
Attempt #10 failed with service unavailable. Continuing to retry for 2m28s
Attempt #11 failed with service unavailable. Continuing to retry for 1m58s
Attempt #12 failed with service unavailable. Continuing to retry for 1m28s
Attempt #13 failed with service unavailable. Continuing to retry for 58s
Attempt #14 failed with service unavailable. Continuing to retry for 28s
1/1 replicas never became healthy!
Healthcheck failed!
is this whats causing it?
137 Replies
Project ID:
N/A
n/a
is this a create react app?
its using Vite
based
could i see your repo?
sure
GitHub
GitHub - HondaChan14/Bit-Source
Contribute to HondaChan14/Bit-Source development by creating an account on GitHub.
you are missing a start command, use the start command from this template
https://github.com/brody192/vite-react-template
you will also need to install serve with
npm i serve
š® ohhh ima look up what serve does
read that templates readme
and also lookup what serve does too
ohhh wow yeah ima check it out now
is this part of the script needed>?
-s -n -L -p $PORT
um yes
okay its having a hard time with
Error: Unknown --listen endpoint scheme (protocol): undefined
is that an error from railway?
sorry i was wrong umm i still get the same
Path: /
Retry window: 5m0s
Attempt #1 failed with service unavailable. Continuing to retry for 4m59s
Attempt #2 failed with service unavailable. Continuing to retry for 4m58s
Attempt #3 failed with service unavailable. Continuing to retry for 4m56s
Okay now the front client side works now im having problem with the server side haha XD
whats wrong with the server
im getting this
Acess to fetch at 'http://localhost:8000/' from origin 'https://bit-source-production-3798.up.railway.app' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:3000' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
its normal for this to happen a few times while your app starts up
I'd thught this had fixed it
const corsOptions = {
origin: process.env.Origin,
};
app.use(cors(corsOptions));
app.use(express.json());
app.use((req, res, next) => {
res.setHeader('Content-Type', 'application/json');
next();
});
but i guess not
you cant request something over http from a site accessed over https
you need to send fetch requets to your backend domain (https://bit-source-production-3798.up.railway.app/), not localhost
ohh so i would change this. So i guess best practice is to make it into an env variable?
yeah an environment variable would be a good idea
ima try it out! hopefully it works but i wanna say you are a master wizard ā¤ļø
no problem š
wow, are you ever in luck
a
RAILWAY_{serviceName}_STATIC_URL
variable was just added, you no longer need to add your own hard coded variable
https://docs.railway.app/develop/variables#railway-provided-variables let me check it out ty!
you can also do this, say you had a service named
energized soda
you could access the domain for it with the variable RAILWAY_SERVICE_ENERGIZED_SODA_URL
what does it mean by service name?
the name of the server service
ohh lol
ohh its not import.meta.env.RAILWAY_BIT_SOURCE_STATIC_URL ?
i forgot this was vite for a sec, my bad
its okay! š
let me know it that works
No š¦
dex-6dcfe425.js:67 SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON is coming from LandingPage
(
status code?
304
are you sure?
show me the address its requesting to please
and what's your backend service's domain?
and I also realized that you'd need to prefix the value from that variable with
https://
my backend is running on port http://localhost:8000
you would need to be running your backend on railway so that when you are running the frontend on railway, the frontend can access the backend
ohh so I would have to make a new project setup?
no just add another service to your current project
add an empty service, set the correct root directory, then add the repo
omg i cant be this dumb <:legend_stare:1082262128028831864>
haha no worries mate
okay i made a new domain for the backend
screenshot of entire project please?
what one is the backend and what one is the front-end
Top is front end bottom is back end
then why does the backend deployment show a commit that was made to the frontend code
hmmm
okay prob just a display bug
i see your backend uses mongodb
you will need to add a mongodb plugin to your project, then setup the variable references
https://docs.railway.app/develop/variables#reference-variables
then show me a screenshot of your backends service variables
im geting this in the deploy log for the backend
npm WARN config production Use
--omit=dev
instead.
[email protected] start node server.jsConnected to database Listening on port 8000 š®
lots to do eh?
it seems like it is connect to mongodb just the fetch on the front end is not getting a repsonse
i dont see mongodb here?
okay i think ima continue this tmrrw as its pretty late for me but ima try to figure it out and if anything ill come back š tysm! i learned alot!
todo tomorrow
tys, you are amazing ā¤ļø
thank you
Sorry im abit behind but i was finally able to add the mongodb plugin
its been a while, catch me up
yeah haha sorry but I was able to change my mongodb string to the MONGO_URL railway plugin provides.
Only issue im having now is that its having a hard time fetching to my backend
is there errors you can show me?
npm WARN config production Use
--omit=dev
instead.
[email protected] start node server.jsMongooseError: The
uri
parameter to openUri()
must be a string, got "undefined". Make sure the first parameter to mongoose.connect()
or mongoose.createConnection()
is a string.
at _createMongoClient (/app/node_modules/mongoose/lib/connection.js:768:11)
at NativeConnection.openUri (/app/node_modules/mongoose/lib/connection.js:705:29)
at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:406:15)
at Object.<anonymous> (/app/server.js:24:6)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47
npm WARN config production Use --omit=dev
instead.
[email protected] start node server.jsMongooseError: The
uri
parameter to openUri()
must be a string, got "undefined". Make sure the first parameter to mongoose.connect()
or mongoose.createConnection()
is a string.
at _createMongoClient (/app/node_modules/mongoose/lib/connection.js:768:11)
at NativeConnection.openUri (/app/node_modules/mongoose/lib/connection.js:705:29)
at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:406:15)
at Object.<anonymous> (/app/server.js:24:6)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47show me your backends service variables please
I just used this
please show me the service variables
ohhh im dumb
there we go
okay so thats fixed.
now this is the issue
const response = await fetch(import.meta.env.RAILWAY_BIT_SOURCE_URL);
what is RAILWAY_BIT_SOURCE_URL
you do not have a service named bit source
youre right i changed am i so dumb? lol
lol
okay i changed it
it doesnt need to be caps
you can have it "Bit Source" and railway will normalize it to BIT_SOURCE
Bit-Source -> BIT_SOURCE
bit source -> BIT_SOURCE
bit's source's -> BIT_S_SOURCE_S
you get the idea
ohh okay
you would need to rebuild your app that is accessing that environment variable
ohh the redeploy?
yes redeploy
same diff
whats the difference with restart and redeploy?
restart will only restart your app itself, this will not refresh the variables
redeploy will rebuild your app again, and this will make the new variables available
š® oohh
hmm okay im still getting
dex-6dcfe425.js:67 SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON i
the bit source service is your frontend, correct?
yes!
what service are you using the RAILWAY_BIT_SOURCE_URL variable in?
the front end
why are you using the frontends own domain in the frontend service?
also, you should not be manually setting that variable, please delete it
i think you might be confused
tell me what you are trying to do
I need the fetch inside the frontend to call the backend since the backend is grabbing data from the github api
you want to fetch the backend, from the frontend?
delete that please, you should not be setting that variable yourself
okay! will do
correct?
yes!
you can use the variable
RAILWAY_SERVICE_BACK_END_URL
you will need to prefix the resulting value with https://
you do not need to create this yourselfconst response = await fetch(import.meta.env.RAILWAY_SERVICE_BACK_END_URL);
^
im not following š¦
do you know what the word prefix means?
ohhh im sorry i thought of it a diofferent way
and then just add typical-cow-production.up.railway.app to the frontend variables
NO!!
you do not need to create this yourself
ahhh
look
https://utilities.up.railway.app/env-vars
i have not set any service variables at all, they are all made by railway automatically
ohhh okay wow i def have alot to learn
perslaps
I do see this in the deply log
**
hmmm yes i know the problem
hold on while i think of a solution
Thanks brody for everything
ohh i tried this
const response = await fetch(
https://${import.meta.env.VITE_RAILWAY_SERVICE_BACK_END_URL}
);
but now getting
Acess to fetch at 'https://typical-cow-production.up.railway.app/' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.you set
VITE_RAILWAY_SERVICE_BACK_END_URL
yourself didnt youi did it on my local to try it out
locally you would need to connect to your locally running backend
i see. okay for now i wanna put a pin on this since i gotta get dinner ready but omg tysm! i feel like im finally getting close
sounds good, im still thinking on the undefined variable
okay tysm! ā¤ļø
it is not the most elegant solution ever, but change your build script to this
VITE_BACK_END_URL=$RAILWAY_SERVICE_BACK_END_URL vite build
then you can use this
like this?
"VITE_BACK_END_URL=$RAILWAY_SERVICE_BACK_END_URL": "vite build",
lol no
"build": "VITE_BACK_END_URL=$RAILWAY_SERVICE_BACK_END_URL vite build"
okay thanks haha
OMG IT FULLY WORKS!
ā„ļø
yippe
tysm for all your help you are truely a god
no problem, always happy to help