deployment successful but frontend does not open

i have successfully deployed the database and server and frontend with logs not showing any apparent issues. The url for the backend opens successfully but the frontend url opens to an error. The only error I can see is "Failed to load resource: the server responded with a status of 503 ()" I cannot see any other error. I think it may be due to the caddyfile not opening the frontend..
152 Replies
Percy
Percy14mo ago
Project ID: N/A
vienna1981
vienna1981OP14mo ago
https://myfitness-client-production.up.railway.app/ this is the url of the frontend 02fafef7-7f8e-49a0-a465-98566e3f143e is the project id Project ID: 02fafef7-7f8e-49a0-a465-98566e3f143e
Brody
Brody14mo ago
hello, can you share your deployment logs https://bookmarklets.up.railway.app/log-downloader/ and your repo please
vienna1981
vienna1981OP14mo ago
GitHub
GitHub - Eugenepython/RAILWAY-FITNESS
Contribute to Eugenepython/RAILWAY-FITNESS development by creating an account on GitHub.
vienna1981
vienna1981OP14mo ago
these are the deploy logs
Brody
Brody14mo ago
you have a typo in the nixpacks.toml file, you have it named nixpack.toml (missing the 's')
vienna1981
vienna1981OP14mo ago
oh" just fixed it now
Brody
Brody14mo ago
okay let me know how that goes!
vienna1981
vienna1981OP14mo ago
i still get an error.....
Brody
Brody14mo ago
can you provide the deployment logs please?
vienna1981
vienna1981OP14mo ago
these are the deploy logs
Brody
Brody14mo ago
make sure you clear any and all build or start commands you may have set in the service settings
vienna1981
vienna1981OP14mo ago
oh wow it works now to open it... but i get the CORS problem again
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
that i thought i knew how to fix ;?
Brody
Brody14mo ago
looking
vienna1981
vienna1981OP14mo ago
oh... i think ive seen the issue, ! i forgot to switch the backendURL back to the railway url
Brody
Brody14mo ago
you are correct, but theres an easy way to do it so that you will never have to manually switch ever again but first lets fix up some things you have node_modules folders and a .env file in your repo add the contents of this link https://www.toptal.com/developers/gitignore/api/node into a .gitignore at the root of your repo then go and delete the node_modules folders and .env from the repo let me know when done!
vienna1981
vienna1981OP14mo ago
delete from repo but not my visual studio code right?
Brody
Brody14mo ago
correct!
vienna1981
vienna1981OP14mo ago
just trying to get this .gigignore file going sorry as ive two already in client and server
Brody
Brody14mo ago
while youre doing that, can i get a screenshot of your entire railway project?
vienna1981
vienna1981OP14mo ago
in terms of
No description
vienna1981
vienna1981OP14mo ago
this is it so i deleted contents of the .env file and deleted node modules
Brody
Brody14mo ago
add the contents of this link https://www.toptal.com/developers/gitignore/api/node into a .gitignore at the root of your repo if this isnt done the node_modules folders will keep coming back
vienna1981
vienna1981OP14mo ago
ok ive done it and trying to push it through... the only problem is that in github when i delete the .env file, i cannot push changes again, until i pull the changes in github which would mean my .env file would be deleted in my local code?
Brody
Brody14mo ago
your local .env file is fine, you dont need to touch that, the .gitignore wont delete anything locally, it just prevents the file/folder from making its way into your repo
vienna1981
vienna1981OP14mo ago
yes but i deleted my .env file in github if i pull changes locally it would delete the local .env file would it not? and without pulling i cant push the .gitignore
Adam
Adam14mo ago
The gitignore makes Github ignore the file, pulling won't delete it but you can always just copy it onto your desktop or whatever until after you pull
vienna1981
vienna1981OP14mo ago
ok so ive pushedthe gitignore.... and added in the .env file i mean i pated the contents back into my local .env file
Brody
Brody14mo ago
delete the .env file from the repo please
vienna1981
vienna1981OP14mo ago
ah ok deleted it completely now
Brody
Brody14mo ago
we want to use environment variables to seamlessly switch between your local backend url when running locally and the backend url while running on railway, so that you aren't switching urls in code before deploy. - in the client railway service set a service variable VITE_BACKEND_API_URL to https://${{myfitness-server.RAILWAY_PUBLIC_DOMAIN}} - in your client code within App.jsx the backendUrl const should be import.meta.env.VITE_BACKEND_API_URL - in your client folder within the project add a .env.local file with VITE_BACKEND_API_URL=http://localhost:3000 in it that way, when developing locally, the local backend url is used automatically from the .env.local file, and when running on railway the backend url from the service variable is used, giving you a seamless transition from developing locally to running on railway! no more switching the backendUrl const around manually!
vienna1981
vienna1981OP14mo ago
in your client folder within the project add a .env.local file with VITE_BACKEND_API_URL=http://localhost:3000 in it sorry does this mean my local code?
Brody
Brody14mo ago
yes you'd create that folder locally, that file would have no problems being in your repo so don't worry about that just never place anything remotely sensitive in a .env.local file
vienna1981
vienna1981OP14mo ago
gotcha ok so ill push the code now
Brody
Brody14mo ago
can you show me the variable I asked you to add to the railway service?
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
this is server variables
No description
Brody
Brody14mo ago
looks good, show me the const variable in app.jsx please
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
i assigned it here
Brody
Brody14mo ago
looks good show me your .env.local file? (not at a computer so it's just faster if you'd show me please)
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
its in my client as opposed to the .env in my server
Brody
Brody14mo ago
it needs to be named .env.local
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
just changed it does the other one too in server?
Brody
Brody14mo ago
.env and a .env.local are two different files that serve different purposes nope, just the client
vienna1981
vienna1981OP14mo ago
ah cool ok
Brody
Brody14mo ago
okay push your changes, I think you've done it all correctly
vienna1981
vienna1981OP14mo ago
sorry...
Brody
Brody14mo ago
sorry?? what happened?
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
sorry cut out stil lget the CORS issues seems to relate to the 3000 address
Brody
Brody14mo ago
will look after lunch
vienna1981
vienna1981OP14mo ago
const prodFrontendURL = process.env.FRONTEND_URL; const devFrontendURL = 'http://localhost:5173'; app.use( cors({ origin: [prodFrontendURL, devFrontendURL], methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', credentials: true, }) ); i had this in servr code ok thanks you! for your help
Brody
Brody14mo ago
you are still hardcoding http://localhost:3000/abs in some places https://github.com/Eugenepython/RAILWAY-FITNESS/blob/main/Client/src/Modals/AbsModal.jsx#L19 https://github.com/Eugenepython/RAILWAY-FITNESS/blob/main/Client/src/Modals/EntryModal.jsx#L97 make sure you are using import.meta.env.VITE_BACKEND_API_URL whenever you fetch something from the backend
vienna1981
vienna1981OP14mo ago
thanks.. i changed that. i still get new errors though ;😂
vienna1981
vienna1981OP14mo ago
No description
Floris
Floris14mo ago
haha but bro that is not Railway im assuming your login is requesting some api somewhere ? error 500 is usually just the code failing and CORS, do you have access to where the login data is getting sent ?
Floris
Floris14mo ago
you can temporarily disable CORS client-side to see if it does work then, several plugins in google chrome webstore CORS disabling/enabling plugin: (https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf)
Allow CORS: Access-Control-Allow-Origin
Easily add (Access-Control-Allow-Origin: *) rule to the response header.
Floris
Floris14mo ago
let me know 🙂 i dont wanna overcomplicate prematurely signature move
vienna1981
vienna1981OP14mo ago
i tried locally
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
fetch(${import.meta.env.VITE_BACKEND_API_URL}/register, { its this line that causes the problem, just wanted to check, as per further up the conversation, this is the right line to use for backend? feel like im close otherwise haha though going sleep now so dont stress about replying haha
Brody
Brody14mo ago
you haven't overcomplicated anything, but when errors aren't properly caught and the framework has to send the 500, most frameworks don't end up setting the cors headers in that case, so the cors issue isn't really the problem, I'm fairly certain they do have cors setup correctly but yes morpheus is correct, 500 is something went wrong with the backend code, please provide deployment logs for the backend
vienna1981
vienna1981OP14mo ago
these are the server logs, new erros
Brody
Brody14mo ago
you still have the .env file in your server folder, please please keep that file out of your repo going forward
vienna1981
vienna1981OP14mo ago
yes just seen that ! ! it seems to keep getting pushed sorry should the gitgnore file not keep it out? deleting it now
Brody
Brody14mo ago
it should
vienna1981
vienna1981OP14mo ago
i deleted the .env file again, it seems to be still looking for a 5432 port? by default? should i use import.meta.env.DB_PORT instead of process.env.DB_PORT, does it read process.env correctly here, and if not revert to the default 5432?
vienna1981
vienna1981OP14mo ago
i had these logs in my database deployment actually let me try DB_USER not PGUSER for the variables sorry i had got the wrong names for the variables DB instead of PG_ "lol" so pleas ignore above messages, didnt want to delete them as thought that might cause even moreonfusion lol
Brody
Brody14mo ago
import.meta.env is only for frontend stuff like vite, you still want to use process.env in node okay so where are we at?
vienna1981
vienna1981OP14mo ago
hey sorry just adjusting code further... i made the stupid mistake among others of using DB for local environment variables and PG for my production enviornmental variables which had confused things
Brody
Brody14mo ago
ah yeah that would cause errors
vienna1981
vienna1981OP14mo ago
hi, so i have progressed a bit further. specifically i used the session middleware which i hadnt realised wasnt being utilised in my development. In development i created another table in the database called 'sessiontable' and was able to connect to it locally. This is to store the session data. However, when using railway, i tried creating this table in my database postgres, along with my 2 other tables, but it doesnt seem to be recognised by my railway server production
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
these are my deployment logs for the database im not sure why there are now issues with the third table
vienna1981
vienna1981OP14mo ago
these are my deployment logs for the server, it says it does not recognise "sessiontable"
vienna1981
vienna1981OP14mo ago
it all worked fine locally
Brody
Brody14mo ago
what do you use to input data into postgres locally?
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
i store it in my postgresql pool.query('SELECT * FROM SESSIONTABLE', (err, result) => { if (err) { console.error('Error querying sessionTable:', err); } else { console.log('Connected to sessionTable successfully'); } }); this confirms connection to sessiontable locally
Brody
Brody14mo ago
you would want to use that same SQL shell to connect to the postgres on railway too do not use the data or query tabs in railway
vienna1981
vienna1981OP14mo ago
oh so dont use a table in railway for this particular purpose? ok so i will try and connect to a remote SQL shell in production...
Brody
Brody14mo ago
exactly!
vienna1981
vienna1981OP14mo ago
my sql shell is only local so id need a remote sql shell
Brody
Brody14mo ago
actually you might like gui software like dbgate better
vienna1981
vienna1981OP14mo ago
im trying to use dbgate for the session data table sorry just progressing with dbgate
Brody
Brody14mo ago
no worries
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
so i created a table called "another name on my db gate and also another called "sessiontitle" "another name" seems to have found its way across from dbgate to postgres database i was just wondering, is there a way to delete tables from the database on railway? there doesnt seem to ben an option to do this, it seems you ahve to delete the whole database?
Brody
Brody14mo ago
please please do not rely on the data or query tabs, I would never trust the information it shows you, use dbgate to delete tables or really to do anything with the database
vienna1981
vienna1981OP14mo ago
as im not sure if the "sessiontitle" table here is the one i created earlier on railway, or a new one pulled from dbgate
Brody
Brody14mo ago
it would be much easier if you exclusively used dbgate going forward, in fact, pretend railway doesn't even have a data or query tab
vienna1981
vienna1981OP14mo ago
oh really, for everything including the two tables i have of "users" and "workout_history"? ok will do so i would have to delete my postgres on railway, and have no database at all on railway?
Brody
Brody14mo ago
yes I can't stress enough how unreliable those data and query tabs are, dbgate is your absolute best bet to do stuff with any database you may host on railway what no, who said anything about deleting your railway database dbgate is simply just a graphical user interface to manage your data on postgres
vienna1981
vienna1981OP14mo ago
so maintain the database on railway, but create the tables on dbgate after linking to railway....?
Brody
Brody14mo ago
right, keep the database on Railway, but use dbgate exclusively for inputting data, deleting tables, rows, checking if the data you or your app created is there, etc
vienna1981
vienna1981OP14mo ago
ok i get you, the tables appear on my postgres databas on railway straight after creation on dbgate so i just wanted to clarify
Brody
Brody14mo ago
yes they do, because that's the database dbgate is putting data into, but the data tab in railway is not reliable, so take what it shows you with a grain of salt
vienna1981
vienna1981OP14mo ago
ah ok im still having porblems deploying my server and its connection to the database though..
vienna1981
vienna1981OP14mo ago
i get these erros
Brody
Brody14mo ago
are you sure your app is connecting to the same database that you are connecting to with dbgate?
vienna1981
vienna1981OP14mo ago
the railway postgres database?
Brody
Brody14mo ago
yes
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
i think they should be by the environemtnal variables...
Brody
Brody14mo ago
yeah that looks good to me
vienna1981
vienna1981OP14mo ago
im sure they were prevously as well connected
Brody
Brody14mo ago
but is that the same database dbgate is connecting to? or are you using dbgate to connect to your local database by mistake?
vienna1981
vienna1981OP14mo ago
i dont think so, as in my dbgate i created the new tables which then appeard on the railway postgres database so they are defintiely connected it console logs the correct environment variables in the logs but just cannot find the tables from the database
Brody
Brody14mo ago
https://github.com/Eugenepython/RAILWAY-FITNESS/blob/main/Server/app.js#L27 you use process.env.PG_NAME when you should use process.env.PG_DATABASE
vienna1981
vienna1981OP14mo ago
i think maybe my pool is not quite correct
Brody
Brody14mo ago
indeed
vienna1981
vienna1981OP14mo ago
yes just saw that !! IVE LITERALLY JUST PUSHED CHAGNES THRU
vienna1981
vienna1981OP14mo ago
yes it works"!!
Brody
Brody14mo ago
awsome!!
vienna1981
vienna1981OP14mo ago
postgres 6349 Server is running on port 6570 Connected to users successfully Connected to sessionTable successfully
vienna1981
vienna1981OP14mo ago
No description
Brody
Brody14mo ago
woohoo
vienna1981
vienna1981OP14mo ago
so im logged in and all working. got some issues with the photos not pulling through haha but i thik i can review this later and try and get it working but main thing i s i can log in etc now thanks s o much again for help and patience
Brody
Brody14mo ago
of course, happy to help!
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
HEY first off, just bought you 3 trains as small token of my appreaciation! the app works well apart from one thing which is the mages overlay. you can see above the difference betwee development and productin <img className = "image-layer" src= './public/images/abs.png' alt="Abs Overlay" style = {theStyle} /> i have the images coded here, i have other images which work as intermidate displays which are coded in the css which come up fine im just not sure why these imags are not showing
vienna1981
vienna1981OP14mo ago
the overlay images are shown in my vsc like this but they do overly properly in development
No description
Floris
Floris14mo ago
holy i accidently read that i coded in css haha im not sure if anyone suggested this alrdy but have you tried an image url? instead of the filepath i can give you a cdn link of all your images if you want to test
vienna1981
vienna1981OP14mo ago
sure ok i could try this, do you mean links to my github images as online urls?
Floris
Floris14mo ago
yes just send me the images and i'll make you cdn links for all of them so you will just specify the web url as source as obviously urls are not prone for filepathing issues or mistakes makes it easier to pinpoint the root issue sometimes send me the images over discord or DM whatever you prefer
vienna1981
vienna1981OP14mo ago
these are all the images here
No description
No description
No description
No description
No description
No description
No description
No description
vienna1981
vienna1981OP14mo ago
i have otherimages stored which work fine, i have them as background images in css as opposed to coded into a module compontent
Floris
Floris14mo ago
lmk if this works
vienna1981
vienna1981OP14mo ago
return ( <div > <img className="image-layer" //src='./public/images/legs.png' src="https://api.xylex.ai/cdn/image/VIENNA_legs.png" alt="Legs Overlay" style = {theStyle} />
</div> ); };
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
thanks but it still doesnt work lol
Floris
Floris14mo ago
send screenshot of console
vienna1981
vienna1981OP14mo ago
this is the deployment logs of the client frontend sorry hang on.... they do appear sorry i will update the urls with the rest o fthe modals i think the issue was that the opacity was set at minimum sorry it actually seems to be working with the online urls now!
vienna1981
vienna1981OP14mo ago
No description
vienna1981
vienna1981OP14mo ago
yes it now seems to be working perfeclty with the online urls for the images thanks! im not sure why the file paths did not work as there was no error in devlopment and no way to test in production thanks for thehelp!
Floris
Floris14mo ago
glad it was resolved!
Brody
Brody14mo ago
thank you so much ❤️
Want results from more Discord servers?
Add your server