#Railway error on path

176 messages · Page 1 of 1 (latest)

halcyon compass
#

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?

vast stumpBOT
#

Project ID: N/A

halcyon compass
#

n/a

onyx juniper
#

is this a create react app?

halcyon compass
#

its using Vite

onyx juniper
#

based

#

could i see your repo?

halcyon compass
#

sure

onyx juniper
#

you will also need to install serve with npm i serve

halcyon compass
#

😮 ohhh ima look up what serve does

onyx juniper
#

read that templates readme

#

and also lookup what serve does too

halcyon compass
#

ohhh wow yeah ima check it out now

halcyon compass
onyx juniper
#

um yes

halcyon compass
#

okay its having a hard time with
Error: Unknown --listen endpoint scheme (protocol): undefined

onyx juniper
#

is that an error from railway?

halcyon compass
#

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

onyx juniper
#

whats wrong with the server

halcyon compass
onyx juniper
halcyon compass
#

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

onyx juniper
#

you cant request something over http from a site accessed over https

halcyon compass
#

ohh so i would change this. So i guess best practice is to make it into an env variable?

onyx juniper
#

yeah an environment variable would be a good idea

halcyon compass
#

ima try it out! hopefully it works but i wanna say you are a master wizard ❤️

onyx juniper
#

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

halcyon compass
#

HYPERS let me check it out ty!

onyx juniper
#

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

halcyon compass
#

what does it mean by service name?

onyx juniper
#

the name of the server service

halcyon compass
#

peepoShy ohh lol

onyx juniper
halcyon compass
#

ohh its not import.meta.env.RAILWAY_BIT_SOURCE_STATIC_URL ?

onyx juniper
#

i forgot this was vite for a sec, my bad

halcyon compass
#

its okay! 🙂

onyx juniper
#

let me know it that works

halcyon compass
#

No 😦
dex-6dcfe425.js:67 SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON is coming from LandingPage
(

onyx juniper
#

status code?

halcyon compass
#

304

onyx juniper
#

are you sure?

#

show me the address its requesting to please

halcyon compass
onyx juniper
#

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://

halcyon compass
onyx juniper
#

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

halcyon compass
#

ohh so I would have to make a new project setup?

onyx juniper
#

no just add another service to your current project

#

add an empty service, set the correct root directory, then add the repo

halcyon compass
#

omg i cant be this dumb legend_stare

onyx juniper
#

haha no worries mate

halcyon compass
#

okay i made a new domain for the backend

onyx juniper
#

screenshot of entire project please?

halcyon compass
onyx juniper
#

what one is the backend and what one is the front-end

halcyon compass
#

Top is front end bottom is back end

onyx juniper
#

then why does the backend deployment show a commit that was made to the frontend code

halcyon compass
#

hmmm

onyx juniper
#

okay prob just a display bug

#

i see your backend uses mongodb

halcyon compass
#

im geting this in the deploy log for the backend

npm WARN config production Use --omit=dev instead.

[email protected] start
node server.js
Connected to database
Listening on port 8000

#

😮

onyx juniper
#

lots to do eh?

halcyon compass
#

it seems like it is connect to mongodb just the fetch on the front end is not getting a repsonse

onyx juniper
halcyon compass
#

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!

halcyon compass
#

tys, you are amazing ❤️

onyx juniper
#

thank you

halcyon compass
#

Sorry im abit behind but i was finally able to add the mongodb plugin

onyx juniper
#

its been a while, catch me up

halcyon compass
#

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

onyx juniper
#

is there errors you can show me?

halcyon compass
#

npm WARN config production Use --omit=dev instead.

[email protected] start
node server.js
MongooseError: 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.js
MongooseError: 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

onyx juniper
#

show me your backends service variables please

halcyon compass
#

I just used this

onyx juniper
#

please show me the service variables

halcyon compass
#

ohhh im dumb

onyx juniper
#

there we go

halcyon compass
#

okay so thats fixed.

#

now this is the issue
const response = await fetch(import.meta.env.RAILWAY_BIT_SOURCE_URL);

onyx juniper
#

what is RAILWAY_BIT_SOURCE_URL

#

you do not have a service named bit source

halcyon compass
#

youre right i changed it

#

why am i so dumb? lol

onyx juniper
#

lol

halcyon compass
#

okay i changed it

onyx juniper
#

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

halcyon compass
#

ohh okay

onyx juniper
#

you would need to rebuild your app that is accessing that environment variable

halcyon compass
#

ohh the redeploy?

onyx juniper
#

yes redeploy

#

same diff

halcyon compass
#

whats the difference with restart and redeploy?

onyx juniper
#

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

halcyon compass
#

😮 oohh

#

hmm okay im still getting
dex-6dcfe425.js:67 SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON i

onyx juniper
#

the bit source service is your frontend, correct?

halcyon compass
#

yes!

#
import React, { useEffect, useState } from 'react';
import IssueBoard from '../../Components/IssueBoard/IssueBoard';

const LandingPage = () => {
    const [issues, setIssues] = useState([]);

    useEffect(() => {
        const fetchIssues = async () => {
            try {
                const response = await fetch(import.meta.env.RAILWAY_BIT_SOURCE_URL);
                const data = await response.json();
                setIssues(data);
            } catch (error) {
                console.error(`${error} is coming from LandingPage`);
            }
        };
        fetchIssues();
    }, []);

    return (
        <div className="bg-red-400 min-h-screen">
            <IssueBoard issues={issues} />
        </div>
    );
};

export default LandingPage;

onyx juniper
#

what service are you using the RAILWAY_BIT_SOURCE_URL variable in?

halcyon compass
#

the front end

onyx juniper
#

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

halcyon compass
#

I need the fetch inside the frontend to call the backend since the backend is grabbing data from the github api

onyx juniper
#

you want to fetch the backend, from the frontend?

halcyon compass
onyx juniper
halcyon compass
#

okay! will do

onyx juniper
halcyon compass
#

yes!

onyx juniper
#

you can use the variable RAILWAY_SERVICE_BACK_END_URL

#

you will need to prefix the resulting value with https://

onyx juniper
halcyon compass
#

const response = await fetch(import.meta.env.RAILWAY_SERVICE_BACK_END_URL);

halcyon compass
#

im not following 😦

onyx juniper
#

do you know what the word prefix means?

#
const response = await fetch(`https://${import.meta.env.RAILWAY_SERVICE_BACK_END_URL}`);
halcyon compass
#

ohhh im sorry i thought of it a diofferent way

#

and then just add typical-cow-production.up.railway.app to the frontend variables

onyx juniper
#

NO!!

onyx juniper
halcyon compass
#

ahhh

onyx juniper
halcyon compass
#

ohhh okay wow i def have alot to learn

onyx juniper
#

perslaps

halcyon compass
#

its different now
dex-676250a3.js:67 GET https://undefined/ net::ERR_NAME_NOT_RESOLVED
(anony

#

I do see this in the deply log


onyx juniper
#

hmmm yes i know the problem

#

hold on while i think of a solution

halcyon compass
#

Thanks brody for everything

halcyon compass
#

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.

onyx juniper
#

you set VITE_RAILWAY_SERVICE_BACK_END_URL yourself didnt you

halcyon compass
#

i did it on my local to try it out

onyx juniper
#

locally you would need to connect to your locally running backend

halcyon compass
#

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

onyx juniper
#

sounds good, im still thinking on the undefined variable

halcyon compass
#

okay tysm! ❤️

onyx juniper
#

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

onyx juniper
#

then you can use this
const response = await fetch(`https://${import.meta.env.VITE_BACK_END_URL}`);

halcyon compass
onyx juniper
#

lol no

#

"build": "VITE_BACK_END_URL=$RAILWAY_SERVICE_BACK_END_URL vite build"

halcyon compass
#

okay thanks haha

#

OMG IT FULLY WORKS!

#

soCute ImLooking ♥️

onyx juniper
#

yippe

halcyon compass
#

tysm for all your help you are truely a god HYPERS