R
Railway4mo ago
Chioma

RAILWAY DEPLOYMENT - AutoDeploy and any deployment isn't happening

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?
356 Replies
Percy
Percy4mo ago
Project ID: N/A
Chioma
Chioma4mo ago
8fc2ded2-11c3-4036-a22b-7b24c3e630b0
Adam
Adam4mo ago
Please send a screenshot of your Railway service's connected repo + auto deploy branch
Chioma
Chioma4mo ago
Hi Adam! Okay it is an angular app so i have a frontend service and backend service...which one would you like to see?
Adam
Adam4mo ago
Whichever one's failing to deploy
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
it is not so much failing is that it's not deploying my latest committ. the deployment it currently ran was a commit from awhile ago
Adam
Adam4mo ago
Please send a screenshot of your service's source repo and branch like the screenshot below
Adam
Adam4mo ago
No description
Chioma
Chioma4mo ago
No description
Adam
Adam4mo ago
Which branch are you deploying to? If the answer is main/master, try removing the source repo and readding it
Brody
Brody4mo ago
they don't have a branch connected in their screenshot
Chioma
Chioma4mo ago
when i disconnect and reconnect the deploy fails
No description
Brody
Brody4mo ago
logs please
Brody
Brody4mo ago
screenshot of your repo please
Chioma
Chioma4mo ago
GitHub
AngularApp/backend at main · ChiomaGrace/AngularApp
Contribute to ChiomaGrace/AngularApp development by creating an account on GitHub.
Brody
Brody4mo ago
delete the node_modules folder
Chioma
Chioma4mo ago
deleted it and failed again
Brody
Brody4mo ago
you still have the node_modules folder
Chioma
Chioma4mo ago
delete in front and back end?
Brody
Brody4mo ago
yes you never want that folder in your repo
Chioma
Chioma4mo ago
got it i remember that and thought i removed it but clearly not
Brody
Brody4mo ago
make sure it's in your .gitignore
Chioma
Chioma4mo ago
it is working now but it is still an old committ and it isnt my latest commit
Brody
Brody4mo ago
push another commit
Chioma
Chioma4mo ago
like just change something to push a commit?
Brody
Brody4mo ago
yeah
Chioma
Chioma4mo ago
same situation not doing it
Brody
Brody4mo ago
what makes you think it's not your latest commit?
Chioma
Chioma4mo ago
i deployed this app first to avoid headaches so all i had to do when i was finished was commit and push so it orginially looked like this
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
ive built a crud app now and locally it looks like this
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
send the link?
Brody
Brody4mo ago
you also have the dist folder in your repo, another folder you never want in there, sorry I didn't notice that sooner add the contents of this https://www.toptal.com/developers/gitignore/api/node,angular as a .gitignore file in your frontend
Chioma
Chioma4mo ago
GitHub
AngularApp/.gitignore at main · ChiomaGrace/AngularApp
Contribute to ChiomaGrace/AngularApp development by creating an account on GitHub.
Chioma
Chioma4mo ago
or are u saying it needs to be in the frontend folder?
Brody
Brody4mo ago
add the one I gave you to the frontend
Chioma
Chioma4mo ago
the contents are identical but my question for u is are u saying put it IN the frontend folder? right now my gitignore is outside both the backend and front end folder so just want to confirm
Brody
Brody4mo ago
contents aren't identical but please put the .gitignore I gave you in the frontend, your current .gitignore is fine where it us
Chioma
Chioma4mo ago
added! still some issue though:/
Brody
Brody4mo ago
gotta delete that dist folder though
Chioma
Chioma4mo ago
ah thank goodness. now it's up. thank u. i thought the gitignore took care of the dist and node modules but it didnt
Brody
Brody4mo ago
it only prevents them from coming back
Chioma
Chioma4mo ago
my data isnt showing though..does the service need a restart?
Brody
Brody4mo ago
where are you storing your data?
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
is your backend connecting to the correct database when on railway?
Chioma
Chioma4mo ago
yes!
Brody
Brody4mo ago
I have no ideas what could be going on then
Chioma
Chioma4mo ago
yeah i think something funky i'll peep at it cause i opened the console and saw this error
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
just a little code issue
Chioma
Chioma4mo ago
yeah i have no idea what though haha. i'll look at it tomorrow. thanks again for the help!! if u think of any ideas of where i should look for that error please feel free to tell me. id take any hints ! ha
Brody
Brody4mo ago
looks like you are calling the front-end when you should be calling the backend
Chioma
Chioma4mo ago
hmm not sure if that's it cause the url has both in it when fully opened
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
im reading stackoverflow and some people say it might be cors but still digging just atrange cause all api calls work locally
Adam
Adam4mo ago
That url looks really funky... Why is it your frontend and backend URLs stapled together?
Brody
Brody4mo ago
all the code for the http calls in your shared.service.ts file look fine with correct usage of the environment variable, so that leaves me to believe the service variable you set was incorrect, so please show us what you have for that
Chioma
Chioma4mo ago
as in where i have NG_APP_BACKEND_URL declared?
Brody
Brody4mo ago
you would have that declared on the frontend service in railway, what do you have it set to?
Chioma
Chioma4mo ago
i realize i didn't set it to anything. do u think that's the issue? when i searched it, it only appeared in the http calls i defined in my shared.service.ts
No description
Chioma
Chioma4mo ago
when looking at a different project i did i declared it like this:
No description
Chioma
Chioma4mo ago
should i replicate that?
Brody
Brody4mo ago
do you not have it declared on the railway frontend service?
Chioma
Chioma4mo ago
oh! yeah i do there
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
what is it set to?
Chioma
Chioma4mo ago
angular-app-backend-production.up.railway.app
No description
Brody
Brody4mo ago
show the raw editor instead please
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
set it to https://${{Angular App Backend.RAILWAY_PUBLIC_DOMAIN}}
Chioma
Chioma4mo ago
howd you know to do that!? i do have another error (unrelated), but what you just sent me fixed the previous error
Brody
Brody4mo ago
I'm been using railway a very long time, it's also not the first time we have done this exact thing also, please take your mongo url out of the frontend's .env.local file, that is only to be used for non sensitive information
Chioma
Chioma4mo ago
so u have to manually change the raw editor? i don't remember doing that last time. what i sent in the first screenshot of the raw editor is what was there when i created the variable, so i need to always manually change it to what u sent in the future?
Brody
Brody4mo ago
I mean you wouldn't have to change anything if you entered the correct reference variable the first time 😅 but yes that what you will need for all backend url variables in this context, of course replace the service name with the applicable service name in the future
Chioma
Chioma4mo ago
but i dont get how i entered it incorrectly i guess cause i clicked generate domain initally here are the notes i took/was following
Brody
Brody4mo ago
it's wrong for two reasons 1. it's not a url, since it's missing the https:// part 2. it's not a reference variable, the variable I gave you is
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
okay so on my step 5 if i put http: angular-app-backend-production.up.railway.app then it would've been fine?
Brody
Brody4mo ago
it would have worked, yes. though that's called a hardcoded variable, we don't want that, we want to use a reference variable. consider this scenario for a hardcoded url like what you just suggested: you change the domain on the backend, maybe you just want to change the railway provided domain or you want to add a domain you bought, but you have hardcoded that variable on the frontend service and have forgotten to update it manually so it is no longer correct and if the domain is incorrect your app fails to call the backend, this is not ideal. now here's the scenario where you use a variable reference like I gave you: you change the domain on the backend again for whatever reason, that reference variable is automatically updated when you deploy the frontend, no intervention needed since it will always reference the backend's domain, just makes things so much easier.
Chioma
Chioma4mo ago
okay i think i understand so in the future i declare the variable and then select one of these options here:
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
is that correct? and not hardcode it
Brody
Brody4mo ago
nope please see the variable I gave you you need to specify the backend service name as it's shown in your project canvas
Chioma
Chioma4mo ago
yeah but i dont understand where this came from at all. this was not an option when i clicked generate domain
Brody
Brody4mo ago
it may reference the domain, but it doesn't really have anything to do with generating a domain, it's something you need to set at your discretion
Chioma
Chioma4mo ago
so this should be changed too then huh? syntax wise..my frontend url?
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
yes, remember everything I've just said and give it a shot!
Chioma
Chioma4mo ago
on it
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
you're missing https:// otherwise, the reference syntax itself is correct
Chioma
Chioma4mo ago
shoot! adjusted and fixed my notes so i def got it down AND that fixed the other error. i can see my data now! that actually helped me learn alot...that mistake thanks for walking me through thar
Brody
Brody4mo ago
happy to help!
Chioma
Chioma4mo ago
also i think i did this because it was the only way it was saving to my database on railway, locally
Brody
Brody4mo ago
it's not, you want to use railway run but even so it doesn't belong in your frontend, since the frontend doesn't connect to mongo
Chioma
Chioma4mo ago
youre right! idk why i did it then okay everything is good to go! thanks for the help gunna start learning react tomorrow and try to do aproject on there have a good night brody! thanks again:)
Brody
Brody4mo ago
no problem! 🙂
Chioma
Chioma4mo ago
Hi @Brody ! Are you still on this thread?
Brody
Brody4mo ago
im here
Chioma
Chioma4mo ago
Lovely! I was using your starter pack as a guide(https://github.com/brody192/create-react-app-starter) to push my react app on railway I (think) I have setup my Railway as needed, so I connected my Repo to my two service variables. This potentially might be a question for Discord Github, but when I push my changes to Github, it does not commit my frontend or backend folder. It only committed the react skeleton if that makes sense. Is this normal?
GitHub
GitHub - brody192/create-react-app-starter
Contribute to brody192/create-react-app-starter development by creating an account on GitHub.
Chioma
Chioma4mo ago
GitHub
GitHub - ChiomaGrace/ReactApp
Contribute to ChiomaGrace/ReactApp development by creating an account on GitHub.
Brody
Brody4mo ago
1. your repo is not a clone of mine, it's just the bare standard app 2. it's not a monorepo like your angular apps are, the repo only contains the front-end
Chioma
Chioma4mo ago
1. yes i did not clone it. as i mentioned i was using yours as a guide/referencing it 2. yes but my structure in vs code does not only contain the front-end. however it only pushed the front end to Github. This is what I found strange
Brody
Brody4mo ago
1. you'd need the Caddyfile and nixpacks.toml from my repo 2. that repo only contains the front-end, therefore pushing to it would only deploy the front-end, perfectly normal
Chioma
Chioma4mo ago
this is what is in my code
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
i have what youre saying! i am just confused why it isnt pushing to Github
Brody
Brody4mo ago
empty commit message
Chioma
Chioma4mo ago
that was an old error ive deleted the remote and redone my first commit and it continues to only do the front end
Brody
Brody4mo ago
this repo is only your front-end
Chioma
Chioma4mo ago
correct haha thats my question it's not pushing my backend folder this is my code setup
Brody
Brody4mo ago
it's not pushing the backend folder because that's not part of the front-ends repo your backend and frontend are in separate repos
Chioma
Chioma4mo ago
ohh really? that's how you set it up for a railway deployment for react? two repos?
Brody
Brody4mo ago
you can do it either way, but that's how you have done it
Chioma
Chioma4mo ago
not intentionally i set up my code like i did in vs then pushed to github and it keeps only showing my frontend so how do i include backend with the same repo
Brody
Brody4mo ago
create a new repo, copy the two folders into the repo
Chioma
Chioma4mo ago
sorry dumb question..but youre saying in github right? not recreate my project in vs code?
Brody
Brody4mo ago
correct in github
Chioma
Chioma4mo ago
this time i am doing by the command line instead of in vs code i got this error
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
just use github desktop
Chioma
Chioma4mo ago
never used that before. hopefully i did it right got this now in github
Chioma
Chioma4mo ago
GitHub
GitHub - ChiomaGrace/ReactApp
Contribute to ChiomaGrace/ReactApp development by creating an account on GitHub.
Chioma
Chioma4mo ago
backend service variable deployed frontend service variable failed
Brody
Brody4mo ago
you have the frontend folder linked to something else, and the nixpacks.toml and caddyfile are in the wrong folder but thats the least of your concerns
No description
Chioma
Chioma4mo ago
linked to something else?
Brody
Brody4mo ago
yeah, i dont know how it works either, but i know that it shouldnt be like that
Chioma
Chioma4mo ago
okay i will delete and try again the desktop github you told me to download im not really understanding how to use
Brody
Brody4mo ago
github desktop, its far easier than git cli
Chioma
Chioma4mo ago
i am so confused haha it just keeps making source repos that i now cant delete
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
i really think i setup my railway correctly so the minute i am able to just upload my code to github i think it'll work wasnt expecting this step to be so problematic
Brody
Brody4mo ago
you are definitely gonna confuse yourself if you try to do source control in vscode. create a new repo, copy your frontend and backend folders into it, push it
Chioma
Chioma4mo ago
no i didnt i used the app like u said
Brody
Brody4mo ago
the screenshot you just sent was you trying to use git in vscode
Chioma
Chioma4mo ago
nope just showing u what has now occured and i cant remove it
Brody
Brody4mo ago
dont do git in vscode please create a new repo with github desktop, click the show in explorer button, copy your frontend and backend folders into it, commit the changes.
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
i dont know what that is
Chioma
Chioma4mo ago
github desktop
Brody
Brody4mo ago
not what mine looks like, but close enough
Chioma
Chioma4mo ago
so what am i clicking there
Brody
Brody4mo ago
plus button
Chioma
Chioma4mo ago
then this correct?
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
its not going to be just the react app, so give it an applicable name
Chioma
Chioma4mo ago
it is cause it's just a practice one for me so create repository yeah?
Brody
Brody4mo ago
its not going to be just the react app, so give it an applicable name
Chioma
Chioma4mo ago
can i not change it later/
Brody
Brody4mo ago
its simplest if you name it correctly now
Chioma
Chioma4mo ago
im fine w the name. so is it cool if we continue? or u really want me to change it that bad
Brody
Brody4mo ago
go for it, im only saying whats best
Chioma
Chioma4mo ago
i get ya this happens
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
follow the steps please create a new repo with github desktop - done! click the show in explorer button copy your frontend and backend folders into it commit the changes.
Chioma
Chioma4mo ago
it doesnt show any of the react files in my frontend
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
but when i click frotend it takes me to that folder containing everything in vs code
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
not really sure what to tell you here, you just need to copy the frontend and backend folders into the folder github desktop makes, it's just drag and drop at that point
Chioma
Chioma4mo ago
i did
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
then commit and publish
Chioma
Chioma4mo ago
it wont let me
Brody
Brody4mo ago
why not
Chioma
Chioma4mo ago
because there is nothing in the frontend as i showed
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
make sure the frontend folder contains the frontend files please
Chioma
Chioma4mo ago
it's not
No description
Brody
Brody4mo ago
github desktop seems to think otherwise
Chioma
Chioma4mo ago
it doesnt when i click on it
Chioma
Chioma4mo ago
Hi Brody, I finally got Github Desktop to work. Sorry about that. My frontend service variable deployed on railway, but here is the error with my backend service. Would you mind terribly taking a look please?
Brody
Brody4mo ago
Error: No start command could be found
Error: No start command could be found
Chioma
Chioma4mo ago
ah shoot got it. didn't hit save in that file all good now thank you !!
Brody
Brody4mo ago
no problem!
Chioma
Chioma4mo ago
Hi again @Brody ! This chat still open?
maxralph01
maxralph014mo ago
What problem are you having? I do not work for Railway. But let's see if we can help you, Chioma.
Chioma
Chioma4mo ago
Okay, thanks! I am having a problem getting my railway backend service variable to work in a react app. Everytime I try to submit my post request, I get a 503 Service Unavailable Error. Here is my component with my form and .env file:
No description
Chioma
Chioma4mo ago
Here is my error:
No description
Chioma
Chioma4mo ago
Can you assist please?
maxralph01
maxralph014mo ago
Yes Seems you are offline as well Let us meet here in exactly an hour. I believe we both should be available by then. Went back to work after waiting for your reply. But I will be available to work it through with you in an hour. Later then
Brody
Brody4mo ago
looks like we are all online now
maxralph01
maxralph014mo ago
Not fully
Brody
Brody4mo ago
line 19 of that jsx file, the fetch call should use the format process.env.REACT_APP_BACKEND_URL + /path your .env file should be a .env.local file instead line #2 of your .env.local file should be REACT_APP_BACKEND_URL=http://127.0.0.1:<the port the backend runs on> as for the railway side of things, you have some misconfigurations there too, but let's get this working locally first
maxralph01
maxralph014mo ago
I am now available
Brody
Brody4mo ago
did I miss anything?
maxralph01
maxralph014mo ago
No. You're in order. I see her problem is more of React than hosting That was why I offered to help
Brody
Brody4mo ago
indeed, there will be some misconfigurations on the railway side of things most likely too
maxralph01
maxralph014mo ago
Apparently At least with your help in familiarizing me with the system, I would say I have some little Railway cloud knowledge Thanks again
Brody
Brody4mo ago
happy to help where I can!
Chioma
Chioma4mo ago
hi guys so sorry for the delay thank you for looking at my screenshots and trouble shooting i have made the suggested changes, but i am still getting the same error
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
you haven't saved the .env.local file by the looks of it
Chioma
Chioma4mo ago
ah i see what u mean cause the variable didnt change in the html. saved it now but still the same error
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
somewhere in code you're not using that backend url environment variable to make an api call the variable name is also incorrect, please carefully read what changes I've asked you to make
Chioma
Chioma4mo ago
yup naming syntax was off. it is working now locally
Brody
Brody4mo ago
awesome, now let's see what service variables you have on the frontend service in railway
Chioma
Chioma4mo ago
i am assuming i need to change this to just BACKEND_URL..is this correct?
No description
Brody
Brody4mo ago
yeah that's for angular, you need to have the applicable environment variable set in the service variables
Chioma
Chioma4mo ago
adjsuted!
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
that's not the same variable you use in code
Chioma
Chioma4mo ago
it is not. apologies
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
what is the raw value of that variable
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
looks good to me
Chioma
Chioma4mo ago
getting a cors error that ive been trying to deal w
Brody
Brody4mo ago
refer to your notes about the express backends you've done when working with angular you would need the same environment variable and cors middleware code
Chioma
Chioma4mo 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.
StackHawk
React CORS Guide: What It Is and How to Enable It
A brief guide on what CORS is and how it works. See it in action and learn how to enable CORS in a React application.
Chioma
Chioma4mo ago
error:
No description
Chioma
Chioma4mo ago
me implementing cors on the backend in my sevrer
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
this post request is being sent to your frontend domain
Chioma
Chioma4mo ago
i thought my backend railway service should have the frontendurl as a variable? like this:
No description
Chioma
Chioma4mo 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
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
No description
Brody
Brody4mo 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.
Chioma
Chioma4mo ago
my frontend domain has the backend url
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
as you can see by these error messages, your frontend is calling the frontend domain
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
now it's correct though now I find it odd that your locally running frontend is making requests to the backend on railway
Chioma
Chioma4mo ago
after i got locally running correctly. i tried to set up production. so i have this in a .env
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
just as a sanity check can you show me your frontend making calls to your locally running backend without issues?
Chioma
Chioma4mo ago
sure thing! one sec
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
can you send the repo again please
Chioma
Chioma4mo ago
GitHub
GitHub - ChiomaGrace/ReactApp
Contribute to ChiomaGrace/ReactApp development by creating an account on GitHub.
Brody
Brody4mo ago
you keep commiting your node_modules folder
Chioma
Chioma4mo ago
i have them in two gitignores!! so idk why thats happening
Chioma
Chioma4mo ago
GitHub
ReactApp/.gitignore at main · ChiomaGrace/ReactApp
Contribute to ChiomaGrace/ReactApp development by creating an account on GitHub.
Brody
Brody4mo ago
what happens if you just open the backend domain in your browser
Chioma
Chioma4mo ago
it just spins but i can see my console logs in railway
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
please send me the domain
Chioma
Chioma4mo ago
i gave you access to the project! i think it shouldve emailed ya
Brody
Brody4mo ago
please send the domain
Brody
Brody4mo ago
there would be a code issue here somewhere
Chioma
Chioma4mo ago
okay. should i make another post and ask the thread? cause ive been poking around today and not too sure what it is
Brody
Brody4mo ago
yeah thats a good idea
maxralph01
maxralph014mo 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. can start*
Chioma
Chioma4mo 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!
maxralph01
maxralph014mo ago
I see. OK. I'll talk with her. Meanwhile, is your app up?
Chioma
Chioma4mo 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? @Brody @maxralph01
Brody
Brody4mo ago
yes you do need the nixpacks.toml and Caddyfile that ive previously linked
Chioma
Chioma4mo 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
React App
Web site created using create-react-app
Brody
Brody4mo ago
build logs please
Chioma
Chioma4mo ago
ooo looks like i solved it! now i will try to tackle the api issue from earlier
Brody
Brody4mo ago
what solved it?
Chioma
Chioma4mo ago
it didn't like that i had a stylesheet i imported on a component that i wasn't using (yet)
Brody
Brody4mo ago
interesting
Chioma
Chioma4mo ago
then the backend errors where coming from my multer/cloudinary packages. 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
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo 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
Cand Dev
YouTube
Deploy React & Node Express App Online in Minutes with Railway (No ...
In this video, you will learn how to easily deploy a React web application and a Node.js/Express server online using Railway. Build AI Image Generator With OpenAI, ReactJs and Tailwindcss - https://youtu.be/Yh2gz1sz-b8 👨‍💻Code: Frontend - https://github.com/candraKriswinarto/genieart backend - https://github.com/candraKriswinarto/genieart-api...
Brody
Brody4mo ago
you already do, at least you did last time i checked your backend code
Chioma
Chioma4mo ago
oh yeah true 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?
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
that video is not good, it leaves so many things out, and that causes you to leave them out
Chioma
Chioma4mo ago
what did i leave out?
Brody
Brody4mo ago
from your last message, you seem to want to leave out some variables?
Chioma
Chioma4mo 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 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 so all i did was leave it as the localhost url and it still works in deployment which surprises me
Brody
Brody4mo ago
yes theres something wrong with your backend deployment
Chioma
Chioma4mo ago
so it is incorrect to use the localhost url? cause it worked locally and deployed
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
just because something "works" doesnt mean its correct you need to find out why your backend on railway is just infinitely loading
Chioma
Chioma4mo ago
it's not haha
Brody
Brody4mo ago
oh you've fixed it?
Chioma
Chioma4mo ago
yeah it doesn't infinite load anymore. it is like this now https://react-app-backend-production.up.railway.app/
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
cool, what was the issue?
Chioma
Chioma4mo ago
the issue now is the api request doesnt go through and it pends
Brody
Brody4mo ago
what was the issue with the backend
Chioma
Chioma4mo ago
^
Brody
Brody4mo ago
oh that was causing it to infinity load?
Chioma
Chioma4mo ago
it appears so
Brody
Brody4mo ago
okay and where can i see an issue with the frontend?
Chioma
Chioma4mo ago
frontend is also deployed w no issue the problem i have now is the api request/submitting a form
Brody
Brody4mo ago
yes please send me a link to where i can see this issue happening
maxralph01
maxralph014mo 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. 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" 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 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) I would also like to try this pattern sometime 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.
Chioma
Chioma4mo ago
Brody
Brody4mo ago
please dont make these kinds of recommendations, i understand you're trying to help but it would only add to the complexity
maxralph01
maxralph014mo 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. Ah OK
Chioma
Chioma4mo ago
i did see this being suggested in some stackoverflows
Brody
Brody4mo ago
chioma, please stick with npm and the nixpacks.toml and Caddyfile
maxralph01
maxralph014mo ago
That is what I have been using on the quick projects I am building in React
Brody
Brody4mo ago
^ while http-server is better than a development server, it is still far from ideal in so many ways
maxralph01
maxralph014mo ago
OK. Please, do so, @Chioma . Just know there is another way for another time. I only feel it is good to have options.
Brody
Brody4mo ago
having options is good, only when the proposed option is a good option
Chioma
Chioma4mo ago
sticking with it sounds good! thanks for trying to help max:)
Brody
Brody4mo ago
agree, thank you okay back to the topic, where am i supposed to be seeing errors?
Chioma
Chioma4mo 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
Brody
Brody4mo ago
its working?
Chioma
Chioma4mo ago
it's submitting but i hav e no idea how cause it's not going to the create function otherwise i would see my console logs in said function but it saves into the mongodb it's very strange
Brody
Brody4mo ago
just seems like a code issue?
Chioma
Chioma4mo ago
it's the api link when it is a http://127.0.0.1:8000/submitResident works like a charm
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
please do not hardcode the url
Chioma
Chioma4mo ago
not my plan just trying to show u the difference one sec for when i use the railway backend service variable
Chioma
Chioma4mo ago
No description
Chioma
Chioma4mo ago
No description
Brody
Brody4mo ago
lets see the backend logs these are local logs
Chioma
Chioma4mo ago
those are backend logs
Brody
Brody4mo ago
nope, those are you local backend logs last I checked railway does not show you a windows terminal
Chioma
Chioma4mo ago
i guess i am not understanding why you want to see the railway logs when we can see the issue locally not working 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
Brody
Brody4mo 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
Chioma
Chioma4mo ago
okay. i thought it would show that locally one sec let me grab them
Chioma
Chioma4mo ago
ah i see what u mean. my logs are there, so it IS working as i expected
Brody
Brody4mo ago
yes, you're probably just incorrectly setting the backend environment variable locally
Chioma
Chioma4mo ago
how come you say that? because i should see those cosole logs in my local termina?
Brody
Brody4mo ago
because your locally running frontend should not be making a call to the backend running on railway therefore you have the variable set wrong
Chioma
Chioma4mo ago
oh yeah thats def how i set it up what should my lcoal front end be making a call to then?
Brody
Brody4mo 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 unless you are doing some specific testing, the locally running frontend should be making a call to the locally running backend
Chioma
Chioma4mo ago
gotcha. i adjusted now
No description
Chioma
Chioma4mo ago
do i do the same for .env.production now? and then put the railway url there
Brody
Brody4mo ago
in this case, production stuff stays in the railway service you should really only have one type of .env file in your frontend and that would be the .env.local file
Chioma
Chioma4mo ago
you know how in angular i could run production mode locally is this not possible in react? this is what i am trying to achieve in my angular app i was using the railway domain locally for my api. i was trying to replicate this in my react app
Brody
Brody4mo ago
railway run npm run dev same thing you do for the backend
Chioma
Chioma4mo ago
and still npm run start for the frontend or npm run build?
Brody
Brody4mo ago
no need to run a build locally, since you run a dev server for the frontend locally
Chioma
Chioma4mo 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!!
Brody
Brody4mo ago
happy to help!
maxralph01
maxralph014mo ago
You're welcome
Chioma
Chioma3mo ago
Hi @Brody! Is this chat still open?
Brody
Brody3mo ago
we are at 445 messages, would you mind opening a new thread?
Chioma
Chioma2mo ago
sure thing! https://discord.com/channels/713503345364697088/1222693316106387566 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
Brody
Brody2mo ago
I dont sorry, is it not something you could google for?
Chioma
Chioma2mo ago
Shoot okay thanks. I thought I'd try to ask ya to see. I've been trying but not having too much luck I'll keep looking!
Brody
Brody2mo ago
well you got me curious, whats the question?
Chioma
Chioma2mo ago
haha you sure?
Brody
Brody2mo ago
yeah I'm just curious, it's unlikely that I'd be able to answer
Chioma
Chioma2mo 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!
TomDoesTech
YouTube
Google OAuth 2.0 With NodeJS (No Passport or googleapis)
Repository: https://github.com/TomDoesTech/Google-OAuth-NodeJS 📚 Concepts & technologies covered - OAuth 2 - JWT - Authentication & authorization - TypeScript - Node.js - Google OAuth 2.0 🌎 Follow me here: Discord: https://discord.gg/4ae2Esm6P7 Twitter: https://twitter.com/tomdoes_tech Facebook: https://www.facebook.com/tomdoestech​ Instagram:...
Brody
Brody2mo ago
ah okay my curiosity is satisfied, and I indeed don't have an answer for that
Chioma
Chioma2mo ago
hahahaha i understand want an update if i figure it out?
Brody
Brody2mo ago
yes!
Chioma
Chioma2mo ago
i figured it out🥹 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
Brody
Brody2mo ago
glad to hear that!!
rwbbets
rwbbets2mo ago
Can you check your DM? 😁 Sorry Brody/Chioma I was wondering if you could help me out with deploying a react native web project on railway! Thanks so much!!
Medim
Medim2mo ago
Can you please open your own thread and describe the issues you are having?