RAILWAY DEPLOYMENT - AutoDeploy and any deployment isn't happening
chiomagrace
HOBBYOP

2 years ago

Hi! I pushed my changes to my Github and usually Railway autodeploys. This time it did not, and I tried to do so manually, and this is also not working. It only deploys the last commit instead of my latest committ. Can someone assist please?

198 Replies

chiomagrace
HOBBYOP

2 years ago


2 years ago

looks good to me


chiomagrace
HOBBYOP

2 years ago

getting a cors error that ive been trying to deal w


2 years ago

refer to your notes about the express backends you've done when working with angular


2 years ago

you would need the same environment variable and cors middleware code


chiomagrace
HOBBYOP

2 years ago

sorry i am being unclear! i understand the error, and why cors is needed (this helped explain that to me pretty well: (https://www.stackhawk.com/blog/react-cors-guide-what-it-is-and-how-to-enable-it/)

what i mean is i think i dealt with the error in the way that is needed, but i keep getting the same error.


chiomagrace
HOBBYOP

2 years ago

error:


chiomagrace
HOBBYOP

2 years ago

me implementing cors on the backend in my sevrer


chiomagrace
HOBBYOP

2 years ago


2 years ago

this post request is being sent to your frontend domain


chiomagrace
HOBBYOP

2 years ago

i thought my backend railway service should have the frontendurl as a variable? like this:


chiomagrace
HOBBYOP

2 years ago

i switched it as youre suggesting, but it's returning undefined because i dont have that variable here whereas with the frontend variable i do have in my backend service


chiomagrace
HOBBYOP

2 years ago


chiomagrace
HOBBYOP

2 years ago


2 years ago

what i said didnt have anything to do with the backends service variables.

your frontend is making api calls to the frontend domain, it needs to make api calls to the backend domain.


chiomagrace
HOBBYOP

2 years ago

my frontend domain has the backend url


chiomagrace
HOBBYOP

2 years ago


2 years ago

as you can see by these error messages, your frontend is calling the frontend domain


chiomagrace
HOBBYOP

2 years ago


2 years ago

now it's correct


2 years ago

though now I find it odd that your locally running frontend is making requests to the backend on railway


chiomagrace
HOBBYOP

2 years ago

after i got locally running correctly. i tried to set up production. so i have this in a .env


chiomagrace
HOBBYOP

2 years ago


2 years ago

just as a sanity check can you show me your frontend making calls to your locally running backend without issues?


chiomagrace
HOBBYOP

2 years ago

sure thing!


chiomagrace
HOBBYOP

2 years ago

one sec


chiomagrace
HOBBYOP

2 years ago


chiomagrace
HOBBYOP

2 years ago


2 years ago

can you send the repo again please


chiomagrace
HOBBYOP

2 years ago


2 years ago

you keep commiting your node_modules folder


chiomagrace
HOBBYOP

2 years ago

i have them in two gitignores!!


chiomagrace
HOBBYOP

2 years ago

so idk why thats happening



2 years ago

what happens if you just open the backend domain in your browser


chiomagrace
HOBBYOP

2 years ago

it just spins but i can see my console logs in railway


chiomagrace
HOBBYOP

2 years ago


2 years ago

please send me the domain


chiomagrace
HOBBYOP

2 years ago

i gave you access to the project! i think it shouldve emailed ya


2 years ago

please send the domain



2 years ago

there would be a code issue here somewhere


chiomagrace
HOBBYOP

2 years ago

okay. should i make another post and ask the thread? cause ive been poking around today and not too sure what it is


2 years ago

yeah thats a good idea


maxralph1
TRIAL

2 years ago

I think you need a mentor.

You should find someone near you.

If you cannot find, I can mentor you. But you must mentor my youngest sister too. She has so much potential but is not utilizing all that wonderful potential.
She plays soccer just like you at the state level in Imo State where we come from. But recently, she just stopped. Someone who got to that level.

She's smart enough to code too if she wanted to, but she hasn't indicated interest in coding. The coding part, she can decide not to. That is no problem.

She's your age and I believe your lingo would rhyme with hers.

If you can get her start getting her back on track for me, I will make you a badass coder.


maxralph1
TRIAL

2 years ago

can start*


chiomagrace
HOBBYOP

2 years ago

Hi Max!

I think with sports, just like anything in life, the individual person has to want it, so I don't know if anything I could say could make her want it to happen if that makes sense. But if she has any questions about soccer or something, I'd be happy to answer them the best I can!


maxralph1
TRIAL

2 years ago

I see. OK.
I'll talk with her.


maxralph1
TRIAL

2 years ago

Meanwhile, is your app up?


chiomagrace
HOBBYOP

2 years ago

It's getting there! I figured out what was causing the deployment to fail on the backend folder and frontend folder.

Now my question is how do I correctly setup a deployment for the react app? Do I need a caddyfile and nixpacks.toml?
Right now my app works deployed when it is basic html. I find it errors when I include routing. My routing works locally, but the routing causes the deployment to fail when deployed. Is there some configuation I am missing that is needed for routing in deployment? <@539512869780455445> <@965732512720617492>


2 years ago

yes you do need the nixpacks.toml and Caddyfile that ive previously linked



chiomagrace
HOBBYOP

2 years ago

Right now my app is deployed just like this: https://testdeployment-frontend-production.up.railway.app/
The buttons in the nav do not route anywhere. The minute I configure them to route somewhere and then push the changes live, the deployment fails


2 years ago

build logs please


chiomagrace
HOBBYOP

2 years ago

ooo looks like i solved it! now i will try to tackle the api issue from earlier


2 years ago

what solved it?


chiomagrace
HOBBYOP

2 years ago

it didn't like that i had a stylesheet i imported on a component that i wasn't using (yet)


2 years ago

interesting


chiomagrace
HOBBYOP

2 years ago

then the backend errors where coming from my multer/cloudinary packages.


chiomagrace
HOBBYOP

2 years ago

locally the api request works (so when the post url is ('http://127.0.0.1:8000/submitResident')
when i try to use the railway variable the api request ${process.env.REACT_APP_BACKEND_URL}/submitResident) is just pending


chiomagrace
HOBBYOP

2 years ago


chiomagrace
HOBBYOP

2 years ago


chiomagrace
HOBBYOP

2 years ago

ive been digging around and i saw this guy use the port key as an environment variable in railway..do u think i should give that a go?
https://www.youtube.com/watch?v=N9hrClMJFqk (1 min 54 sec)
he seemed to have success w configuring that way


2 years ago

you already do, at least you did last time i checked your backend code


chiomagrace
HOBBYOP

2 years ago

oh yeah true


chiomagrace
HOBBYOP

2 years ago

i guess you dont need a frontend and backend service variables for react? as long as i have the port key it seems to work?


chiomagrace
HOBBYOP

2 years ago


2 years ago

that video is not good, it leaves so many things out, and that causes you to leave them out


chiomagrace
HOBBYOP

2 years ago

what did i leave out?


2 years ago

from your last message, you seem to want to leave out some variables?


chiomagrace
HOBBYOP

2 years ago

no. i am saying when i orginially set this app for deployment i followed how i did it for angular. so my frontend service had a backendurl variable and vice versa with my backend service


chiomagrace
HOBBYOP

2 years ago

then when i tried to use the backendurl in a .env file it wouldnt work. however when the api link was the localhost it did work


chiomagrace
HOBBYOP

2 years ago

so all i did was leave it as the localhost url and it still works in deployment


chiomagrace
HOBBYOP

2 years ago

which surprises me


2 years ago

yes theres something wrong with your backend deployment


chiomagrace
HOBBYOP

2 years ago

so it is incorrect to use the localhost url?


chiomagrace
HOBBYOP

2 years ago

cause it worked locally and deployed


chiomagrace
HOBBYOP

2 years ago


2 years ago

just because something "works" doesnt mean its correct


2 years ago

you need to find out why your backend on railway is just infinitely loading


chiomagrace
HOBBYOP

2 years ago

it's not


chiomagrace
HOBBYOP

2 years ago

haha


2 years ago

oh you've fixed it?


chiomagrace
HOBBYOP

2 years ago

yeah it doesn't infinite load anymore. it is like this now



chiomagrace
HOBBYOP

2 years ago


chiomagrace
HOBBYOP

2 years ago

the issue now is the api request doesnt go through and it pends


2 years ago

cool, what was the issue?


chiomagrace
HOBBYOP

2 years ago

the issue now is the api request doesnt go through and it pends


2 years ago

what was the issue with the backend


chiomagrace
HOBBYOP

2 years ago

^


2 years ago

oh that was causing it to infinity load?


chiomagrace
HOBBYOP

2 years ago

it appears so


2 years ago

okay and where can i see an issue with the frontend?


chiomagrace
HOBBYOP

2 years ago

frontend is also deployed w no issue


chiomagrace
HOBBYOP

2 years ago

the problem i have now is the api request/submitting a form


2 years ago

yes please send me a link to where i can see this issue happening


maxralph1
TRIAL

2 years ago

Sorry for being late to the party. I was having the same issue with React on Railway.
Another way is to use "yarn" for your package manager instead of "npm".
I usually do not want to go through the stress of adding extra files.


maxralph1
TRIAL

2 years ago

And when using yarn in your package manager, add this line to your list of commands in your package.json file:
"start": "npx http-server ./dist"


maxralph1
TRIAL

2 years ago

This line uses the http-server package to serve your react files.
Railway on seeing that command, I noticed, installed the http-server for me and served my files


maxralph1
TRIAL

2 years ago

And finally,
For the settings on your Railway, change the build command to:
"yarn build" (without the quotes of course)

And the start command, make it:
"yarn start" (without the quotes of course)


maxralph1
TRIAL

2 years ago

I would also like to try this pattern sometime


maxralph1
TRIAL

2 years ago

The routing I use currently is HashRouter (if you are using react-router).
But one thing about this is that your URL looks untidy.
Give it a browse.
Replace BrowserRouter with HashRouter.



2 years ago

please dont make these kinds of recommendations, i understand you're trying to help but it would only add to the complexity


maxralph1
TRIAL

2 years ago

Again, if you want to use BrowserRouter on production, there is another pattern yet. I will give you a detailed guide on how I implemented it, if it works. Because I am planning on using it on my next project.


maxralph1
TRIAL

2 years ago

Ah OK


chiomagrace
HOBBYOP

2 years ago

i did see this being suggested in some stackoverflows


2 years ago

chioma, please stick with npm and the nixpacks.toml and Caddyfile


maxralph1
TRIAL

2 years ago

That is what I have been using on the quick projects I am building in React


2 years ago

^


2 years ago

while http-server is better than a development server, it is still far from ideal in so many ways


maxralph1
TRIAL

2 years ago

OK. Please, do so, <@1150235403157241856> .
Just know there is another way for another time.
I only feel it is good to have options.


2 years ago

having options is good, only when the proposed option is a good option


chiomagrace
HOBBYOP

2 years ago

sticking with it sounds good! thanks for trying to help max:)


2 years ago

agree, thank you


2 years ago

okay back to the topic, where am i supposed to be seeing errors?


chiomagrace
HOBBYOP

2 years ago

i made some more changes so i think you can see now. if you go to the create component and look at the console log when you try to submit something


2 years ago

its working?


chiomagrace
HOBBYOP

2 years ago

it's submitting


chiomagrace
HOBBYOP

2 years ago

but i hav e no idea how


chiomagrace
HOBBYOP

2 years ago

cause it's not going to the create function


chiomagrace
HOBBYOP

2 years ago

otherwise i would see my console logs in said function


chiomagrace
HOBBYOP

2 years ago

but it saves into the mongodb


chiomagrace
HOBBYOP

2 years ago

it's very strange


2 years ago

just seems like a code issue?


chiomagrace
HOBBYOP

2 years ago

it's the api link


chiomagrace
HOBBYOP

2 years ago


chiomagrace
HOBBYOP

2 years ago

works like a charm


chiomagrace
HOBBYOP

2 years ago

1210732098638319600


chiomagrace
HOBBYOP

2 years ago

1210732118372515800


2 years ago

please do not hardcode the url


chiomagrace
HOBBYOP

2 years ago

not my plan


chiomagrace
HOBBYOP

2 years ago

just trying to show u the difference


chiomagrace
HOBBYOP

2 years ago

one sec for when i use the railway backend service variable


chiomagrace
HOBBYOP

2 years ago

1210733487301070800


chiomagrace
HOBBYOP

2 years ago

1210733514518044700


2 years ago

lets see the backend logs


2 years ago

these are local logs


chiomagrace
HOBBYOP

2 years ago

those are backend logs


2 years ago

nope, those are you local backend logs


2 years ago

last I checked railway does not show you a windows terminal


chiomagrace
HOBBYOP

2 years ago

i guess i am not understanding why you want to see the railway logs when we can see the issue locally not working


chiomagrace
HOBBYOP

2 years ago

my angular app when i was using railway run start when i submitted a form, i could see the logs and then check on railway and see the data stored in my database
what i am trying to explain here is that my react ap with the railay api i cannot see the logs of my create function


2 years ago

because your frontend is making an api call to the backend that's running on railway, therefore the backend on railway would have the logs


chiomagrace
HOBBYOP

2 years ago

okay. i thought it would show that locally


chiomagrace
HOBBYOP

2 years ago

one sec let me grab them


chiomagrace
HOBBYOP

2 years ago

ah i see what u mean. my logs are there, so it IS working as i expected

1210776410122231838


2 years ago

yes, you're probably just incorrectly setting the backend environment variable locally


chiomagrace
HOBBYOP

2 years ago

how come you say that? because i should see those cosole logs in my local termina?


2 years ago

because your locally running frontend should not be making a call to the backend running on railway


2 years ago

therefore you have the variable set wrong


chiomagrace
HOBBYOP

2 years ago

oh yeah thats def how i set it up


chiomagrace
HOBBYOP

2 years ago

what should my lcoal front end be making a call to then?


2 years ago

in this screenshot you have a .env file in your frontend, you should not have a .env file in your frontend, it should be a .env.local file like we have talked about


2 years ago

unless you are doing some specific testing, the locally running frontend should be making a call to the locally running backend


chiomagrace
HOBBYOP

2 years ago

gotcha. i adjusted now

1210778130562814000


chiomagrace
HOBBYOP

2 years ago

do i do the same for .env.production now? and then put the railway url there


2 years ago

in this case, production stuff stays in the railway service


2 years ago

you should really only have one type of .env file in your frontend and that would be the .env.local file


chiomagrace
HOBBYOP

2 years ago

you know how in angular i could run production mode locally


chiomagrace
HOBBYOP

2 years ago

is this not possible in react?


chiomagrace
HOBBYOP

2 years ago

this is what i am trying to achieve


chiomagrace
HOBBYOP

2 years ago

in my angular app i was using the railway domain locally for my api. i was trying to replicate this in my react app


2 years ago

railway run npm run dev


2 years ago

same thing you do for the backend


chiomagrace
HOBBYOP

2 years ago

and still npm run start for the frontend or npm run build?


2 years ago

no need to run a build locally, since you run a dev server for the frontend locally


chiomagrace
HOBBYOP

2 years ago

right on. the lightbulb in my head finally went on
i think what i was struggling with was not seeing my logs but when u said check railway and i saw them it helped clear a lot of confusion for me
thanks soo much brody. always make things super clear and i leave w a better understanding. appreciate your time!!


2 years ago

happy to help!


maxralph1
TRIAL

2 years ago

You're welcome


chiomagrace
HOBBYOP

2 years ago

Hi @Brody! Is this chat still open?


2 years ago

we are at 445 messages, would you mind opening a new thread?


chiomagrace
HOBBYOP

2 years ago

sure thing!



chiomagrace
HOBBYOP

2 years ago

Hi @Brody

I don't have a Railway related question. My question is for NodeJs. Do you know a Discord community I can go to join and ask by chance? The only one I saw/tried to join didn't allow me to post questions


2 years ago

I dont sorry, is it not something you could google for?


chiomagrace
HOBBYOP

2 years ago

Shoot okay thanks. I thought I'd try to ask ya to see.
I've been trying but not having too much luck


chiomagrace
HOBBYOP

2 years ago

I'll keep looking!


2 years ago

well you got me curious, whats the question?


chiomagrace
HOBBYOP

2 years ago

haha you sure?


2 years ago

yeah I'm just curious, it's unlikely that I'd be able to answer


chiomagrace
HOBBYOP

2 years ago

I am attempting to implement a Google authorization on my React Native App. I've read a lot and watched a lot of videos, but this one made the most sense to me, so I attempted this method (https://www.youtube.com/watch?v=Qt3KJZ2kQk0)

I am at 21 minutes in the video. For Tom in his video, when he clicked on the button to trigger his api call, the Google dialog box appeared. For me, this doesn't happen. So that's where I am stuck

I do not get any errors, and I do see the same console logs at this point in the video. The only difference is the Google dialog box doesn't pop up for me. S'close!


2 years ago

ah okay my curiosity is satisfied, and I indeed don't have an answer for that


chiomagrace
HOBBYOP

2 years ago

hahahaha


chiomagrace
HOBBYOP

2 years ago

i understand


chiomagrace
HOBBYOP

2 years ago

want an update if i figure it out?


2 years ago

yes!



chiomagrace
HOBBYOP

2 years ago

i figured it out🥹


chiomagrace
HOBBYOP

2 years ago

but on react native web so works in a web browser
now i have to do it for android and ios. it is a processs


2 years ago

glad to hear that!!


nworbdier
HOBBY

2 years ago

Can you check your DM? 😁


nworbdier
HOBBY

2 years ago

Sorry Brody/Chioma I was wondering if you could help me out with deploying a react native web project on railway! Thanks so much!!


2 years ago

Can you please open your own thread and describe the issues you are having?


chiomagrace
HOBBYOP

a year ago

Hi Brody! Still active here?


a year ago

He can be! @Brody


a year ago

👋


Loading...