R
Railwayβ€’9mo ago
CookieMonzteh

Deploying Shared Mono Repo confusion

So im either slow and or the documentation doesnt do a good job of describing whats going on and its very confusing to me. Im currently trying to setup my monorepo and the way I have my project setup is like so with the image ive attacheched. This would fall under a shared mono repo and Im trying to follow the docs and it says to run a custom start command like nom run start:backend but I dont understand what that means or how it works. The way my project currently works is I run npm run start for my frontend and npm run dev for my server so I assumed id just add 2 start commands but thats not the case?
"scripts": {
"start": "react-scripts start",
"dev": "npx nodemon server.js",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"scripts": {
"start": "react-scripts start",
"dev": "npx nodemon server.js",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Im extremely new when it comes to hosting and deploying so it feels a bit all over the place in trying to understand these things and it seems like the docs take you from one link to another very frequently rather than having everything you need on a page and its kinda overwhelming and hard to understand so any resource, docs, or explanation for setting something like this up would be very appreciated πŸ™
No description
393 Replies
Percy
Percyβ€’9mo ago
Project ID: 87f56f88-5de7-4a88-8ed9-9e3f3af4ea9f
CookieMonzteh
CookieMonztehOPβ€’9mo ago
87f56f88-5de7-4a88-8ed9-9e3f3af4ea9f The way im somewhat understanding this is that you make 2 seperate services using the same monorepo but im guessing and i dont want to just be guessing
Brody
Brodyβ€’9mo ago
the documentation doesnt do a good job of describing whats going on
it really doesn’t, the documentation on mono repos of any kind needs a lot of love, its absolutely not you.
The way im somewhat understanding this is that you make 2 seperate services using the same monorepo but im guessing and i dont want to just be guessing
you have guessed correctly, two services, from the same repo, and you would set the start commands (in the service settings) to the applicable command for what you want that service to run. only issues im seeing here is that your start script for the frontend starts a development server, this will have very poor performace and use quite a lot of resources. same with the dev script for the backend, you never want to use nodemon in production.
CookieMonzteh
CookieMonztehOPβ€’9mo ago
the whole reason i went back to using my mono repo was so i didnt have to do this πŸ€¦β€β™‚οΈ ive been working for weeks trying to get my project thats pretty much already done hosted and its been such a nightmare
Brody
Brodyβ€’9mo ago
two apps need two railway services
CookieMonzteh
CookieMonztehOPβ€’9mo ago
so just to clarify my ignorance...theres no such thing as a single full stack hosted service anywhere? or is that just in railways case?
Brody
Brodyβ€’9mo ago
there is, but your frontend and backend are two apps, even if they share types, so they need two services
CookieMonzteh
CookieMonztehOPβ€’9mo ago
currently I technically already have 2 services setup, my backend is on railway and front end on netlify...but ive been having a bunch of cors issues and a guy thats been helping me told me to use the mono repo I had before and setup a proxy so I dont have the issues that ive been having
Brody
Brodyβ€’9mo ago
yeah you still need two services for that, we can setup a proxy if thats what you would like https://railway.app/project/35d8d571-4313-4049-9699-4e7db7f02a2f
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah just give me a second cuz now I have to rethink and understand a bunch of stuff, imma check the link rq
Brody
Brodyβ€’9mo ago
theres really not much you need to do to get your mono repo deploying on railway, you are just starting dev servers, and not doing that is an easy fix the link is what your project should look like (maybe minus a database) (i have a template for the proxy)
CookieMonzteh
CookieMonztehOPβ€’9mo ago
Oh yeah no thats not the issue at all, its just I started trying to work in a way that allowed me to use a single service for this so I could use creact react apps proxy because the way i was previously working before was how you mentioned but the guy helping me just told me that having them split up like that makes everything harder which I could honestly verify because ive yet to get my sessions, cookies, and cors issues to work. he suggested that its still possible on railway via docker config? πŸ€” "if everything is in the same project (ie one git clone will give you everything you need) then you can do a multi-stage docker build that build your frontend and then pass that to the backend as static assets to be served as part of the api and that approach will also make it easier to diagnose locally since you can run the build on your own computer and do a production build to make sure it works properly before handing it to railway"
Brody
Brodyβ€’9mo ago
yes you can have your backend serve the frontend, that is certainly one way, personally its not something i would do
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah i mean im kinda out of options man 🀷 so i kinda have to try something else because doing it that way hasnt worked for me and I dont know why so doing this is at least progress towards something
Brody
Brodyβ€’9mo ago
three options - two railway services - two railway services + a proxy - one service - serve the frontend from the backend
CookieMonzteh
CookieMonztehOPβ€’9mo ago
i wouldnt either tho
Brody
Brodyβ€’9mo ago
you pick, ill help with whatever you pick
CookieMonzteh
CookieMonztehOPβ€’9mo ago
alright so lets do this then
Brody
Brodyβ€’9mo ago
what option?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
2.)
Brody
Brodyβ€’9mo ago
good choice
CookieMonzteh
CookieMonztehOPβ€’9mo ago
question tho
Brody
Brodyβ€’9mo ago
of course
CookieMonzteh
CookieMonztehOPβ€’9mo ago
does it have to be 2 railway apps specifically? because like i mentioned earlier I already have a bakcend service and my frontend is on railway so its still 2 services but one of them in netlify? does that matter for setting up the proxy? lemme send the link
Brody
Brodyβ€’9mo ago
did you want to keep the frontend on netlify?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
87f56f88-5de7-4a88-8ed9-9e3f3af4ea9f it doesnt make a difference to me tbh but id maybe lean to keep it there because I wanna keep my cost down on railway id guess if switching it makes things easier...then no
Brody
Brodyβ€’9mo ago
keeping it on netlify would have the reverse effect, since if kept on netlify you will be charged extra egress from the proxy communications to the off-site frontend
CookieMonzteh
CookieMonztehOPβ€’9mo ago
oh? so it would cost more not having it in railway...interesting. I always see that word egress but didnt know thats what it meant in that case yeah i can have it on railway
Brody
Brodyβ€’9mo ago
it would also have far more latency egress is the amount of data out of the network
CookieMonzteh
CookieMonztehOPβ€’9mo ago
interesting, guess that makes sense. I thought storage would have cost more but goes to show how little i know lol im setting it up rn
Brody
Brodyβ€’9mo ago
the frontend doesn't use any charge-able storage on railway you will need to make some changes to your repo though, because as mentioned before, you are running both the frontend and backend in development modes we want to save money here not burn it the less resources your services use, the cheaper they are to run
CookieMonzteh
CookieMonztehOPβ€’9mo ago
oh yeah you mentioned alot of stuff earlier about not using nodemon and whatnot
Brody
Brodyβ€’9mo ago
share or add me to your repo and I'll see what changes need to be made
CookieMonzteh
CookieMonztehOPβ€’9mo ago
sry if i didnt catch everything i was talking back and forth with someone which one?
Brody
Brodyβ€’9mo ago
no worries
CookieMonzteh
CookieMonztehOPβ€’9mo ago
both?
Brody
Brodyβ€’9mo ago
you have a mono repo, it is only one repo? wdym both?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
also this channel doesnt have vc?
Brody
Brodyβ€’9mo ago
nope, no VC needed
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ahhh, my apologies. I keep confusing people with this so I essentially have 3 repos. one is the monorepo and the 2 other ones are a divide of that mono repo so my frontend and backend. What i currently have hosted is the 2 seperate repos not my mono repo. Should I start from scratch and just use that monorepo instead of the two?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
yeah that's quite convoluted, you should remove those two repos designated backend and frontend
CookieMonzteh
CookieMonztehOPβ€’9mo ago
gotcha
Brody
Brodyβ€’9mo ago
then add me to the first repo, my gh username is brody192 unless it's public, in that case just send the link
CookieMonzteh
CookieMonztehOPβ€’9mo ago
added
Brody
Brodyβ€’9mo ago
looking
CookieMonzteh
CookieMonztehOPβ€’9mo ago
no worries, im looking over stuff to and trying to make it work again in local dev
Brody
Brodyβ€’9mo ago
dont get too dug in, theres a good chance theres some changes we need to make that might interfere with what you are doing
CookieMonzteh
CookieMonztehOPβ€’9mo ago
mmm yeah.... every since i hosted my stuff the singular thing thats given me a problem and even now in local dev is giivng me an issue is user authentications / sessions / cookies...im just at a loss on what to do in that regard.
Brody
Brodyβ€’9mo ago
well this repo is technically a monorepo, its mushed together, this makes both it hard to run both locally and on railway
CookieMonzteh
CookieMonztehOPβ€’9mo ago
I thought that was supposed to make things easier?
Brody
Brodyβ€’9mo ago
i can't see how this makes anything easier, there is a right and a wrong way to do a shared monorepo, and this is not what you want to do, we will get you fixed up though
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ah thats what you meant. gotcha
Brody
Brodyβ€’9mo ago
ill try my hand at a pr to get this repo in shape
CookieMonzteh
CookieMonztehOPβ€’9mo ago
sounds good. thank you πŸ™ I gtg to work but ill be back and go over the changes. oddly enough my local dev sessions arent saving either which is the same problemI had when i had it hosted so in a way this could be a good thing or a hint since again its most likely configs
Brody
Brodyβ€’9mo ago
sounds good
CookieMonzteh
CookieMonztehOPβ€’9mo ago
if theres any repos or documentation you follow or suggest for how to properly set a monorepo up rather than slapping them all in the root directory like I did lmk to πŸ‘
Brody
Brodyβ€’9mo ago
I just googled how to setup a npm workspace haha did you see my branch?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ah, yeah i see it now
Brody
Brodyβ€’9mo ago
yep thats it okay so do you wanna walk through how to deploy my branch?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
I think I should quickly look over how all this works rq first, when I finish reading this and going over it ill lyk
Brody
Brodyβ€’9mo ago
sounds good side note, I tried to separate the two apps best I could, but it's likely that I left bits and pieces of them in either folder, so when you have the time go through and clean that up
CookieMonzteh
CookieMonztehOPβ€’9mo ago
Yeah i was assuming that too, still thanks 1000X might have some quick questions as I read
Brody
Brodyβ€’9mo ago
of course
CookieMonzteh
CookieMonztehOPβ€’9mo ago
for example the
"workspaces": ["./packages/*"]
"workspaces": ["./packages/*"]
is just return an array of both folder paths? so its essentially a shorter version of?
"workspaces": ["./packages/frontend", "./packages/backend"]
"workspaces": ["./packages/frontend", "./packages/backend"]
im assuming the * just means return all files
Brody
Brodyβ€’9mo ago
correct, there may be a time when you don't want every folder in the packages directory to be a workspace, but we currently do, so a wildcard is easiest
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ah wait i just read more oops lol they tell you that down below. Ok yeah this makes sense. The only thing im noticing that im not seeing is this? what are these?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
"start": "caddy run", ? railway specific files and scripts?
Brody
Brodyβ€’9mo ago
https://caddyserver.com/ railway does not run a frontend like netlify or vercel, it will run your app as is, and use the default start script, the default start script starts a development server, so that is what railway would run, so we need to provide a custom build plan to download caddy and run it. nixpacks.toml installs caddy the Caddyfile is the config for caddy and the start command runs caddy
CookieMonzteh
CookieMonztehOPβ€’9mo ago
wow how in the world do you know this πŸ’€
Brody
Brodyβ€’9mo ago
this isn't my first rodeo
CookieMonzteh
CookieMonztehOPβ€’9mo ago
clearly lol must have been a headache, I just assumed that it would handle it or at the very least recognize that and make a custom build command but i would have never guessed having to manually do this yourself
Brody
Brodyβ€’9mo ago
nope railway is not like that, your code is ran as is, and if it's only setup to run a development server, than that's what will be ran
CookieMonzteh
CookieMonztehOPβ€’9mo ago
hmm I think I understand, so netlfy and vercel essentially make it for you but like you said railway makes it as is, so why isnt my backend caddy server.js for example? because node is setting up a backend server therefor node for backend is what caddy is for the front end on build/run commands?
Brody
Brodyβ€’9mo ago
you can think of caddy as a file server, nothing to do with node. its simply serving the built website files
CookieMonzteh
CookieMonztehOPβ€’9mo ago
definitely will do more research on it but I think i get the jist imma test out the repo rn
Brody
Brodyβ€’9mo ago
locally?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ye
Brody
Brodyβ€’9mo ago
okay cool, there is a procedure to deploy onto railway, so let me know when you wanna do that
CookieMonzteh
CookieMonztehOPβ€’9mo ago
sounds good thank you πŸ™ just attempted running it and I think the root package.json file needs a start script
Brody
Brodyβ€’9mo ago
nope npm run frontend:dev and npm run backend:dev
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ahhhh i was doing :start mb hmmm yeah thats weird i get the same error
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
when i used :start it said the same thing
Brody
Brodyβ€’9mo ago
please see the commands i have sent here
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah those are what I put copy and pasted and everything I meant i get the same error except instead of start its combplaining about the dev
Brody
Brodyβ€’9mo ago
did you change anything? it works for me
CookieMonzteh
CookieMonztehOPβ€’9mo ago
nope, do i need to npm init maybe?
Brody
Brodyβ€’9mo ago
nope, it just works for me, show me your package.json from your backend
CookieMonzteh
CookieMonztehOPβ€’9mo ago
{
"name": "paragon-app-backend",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"@aws-sdk/client-s3": "^3.377.0",
"@aws-sdk/s3-request-presigner": "^3.252.0",
"axios": "^1.2.1",
"bcrypt": "^5.1.0",
"connect-session-sequelize": "^7.1.7",
"html-react-parser": "^3.0.8",
"lodash": "^4.17.21",
"multer": "^1.4.5-lts.1",
"mysql2": "^2.3.3",
"passport": "^0.6.0",
"passport-google-oauth2": "^0.2.0",
"sequelize": "^6.32.1",
"uuid": "^9.0.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"dev": "npx nodemon server.js",
"start": "node server.js"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "^7.22.9",
"nodemon": "^2.0.20"
}
}
{
"name": "paragon-app-backend",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"@aws-sdk/client-s3": "^3.377.0",
"@aws-sdk/s3-request-presigner": "^3.252.0",
"axios": "^1.2.1",
"bcrypt": "^5.1.0",
"connect-session-sequelize": "^7.1.7",
"html-react-parser": "^3.0.8",
"lodash": "^4.17.21",
"multer": "^1.4.5-lts.1",
"mysql2": "^2.3.3",
"passport": "^0.6.0",
"passport-google-oauth2": "^0.2.0",
"sequelize": "^6.32.1",
"uuid": "^9.0.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"dev": "npx nodemon server.js",
"start": "node server.js"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "^7.22.9",
"nodemon": "^2.0.20"
}
}
Brody
Brodyβ€’9mo ago
can you run start you are running that command from the root right?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yep, you can see the command and the directory in the sc, i tried both start and dev and get that error lemme try something tried npm installing to make sure and restarded and yep i still get them,
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
I doubt it was the way I fetched the branch might be this
CookieMonzteh
CookieMonztehOPβ€’9mo ago
Stack Overflow
error: This is probably not a problem with npm. There is likely add...
In my project, I'm using Angular6 for the frontend. Now what I'm trying to do is deploy my project which is in remote server into the actual server. I'm using npm run build -prod command to build the
CookieMonzteh
CookieMonztehOPβ€’9mo ago
imma see if i can figure it out but i think its most likely something do do with this
Brody
Brodyβ€’9mo ago
it still works for me locally, something is misconfigured on your end, try deleting and redownloading the branch
CookieMonzteh
CookieMonztehOPβ€’9mo ago
only other solution im seeing is to delete my node modules and resinstall
Brody
Brodyβ€’9mo ago
cant hurt to try
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
πŸ˜‚ i dont lol
Brody
Brodyβ€’9mo ago
lmao
CookieMonzteh
CookieMonztehOPβ€’9mo ago
just noticed something different but could you screen shot what your root directory looks like this is mine now
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
what version of node are you using
Brody
Brodyβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ok thats what I thought. Yeah for some reason I had a nodemodules folder in my root, but now mine looks like that and i have one module folder in the frontend and backend folders....still getting that error though πŸ’€ , and the error doesnt give much context I looked in here too
Brody
Brodyβ€’9mo ago
have you tried this?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yep even vscode is asking me wtf im doing
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
i saw that too
CookieMonzteh
CookieMonztehOPβ€’9mo ago
just so we are on the same page....git checkout -t origin/branch-name is what im doing for that branch? i might just make a completely seperate local repo and clonse it just to make sure
Brody
Brodyβ€’9mo ago
i dont know, i dont use git cli
CookieMonzteh
CookieMonztehOPβ€’9mo ago
imma bout to fight my computer lol, lemme try cloning on a clean repo nvm thats not a thing you can do in git
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah no you can only clone from the master branch and get the branches through it
Brody
Brodyβ€’9mo ago
what node verison are you using
CookieMonzteh
CookieMonztehOPβ€’9mo ago
i was actually about to ask the same thing earlier. 14.17.0 im like 99% sure this is a node issue
Brody
Brodyβ€’9mo ago
im on 18 lts 14 is far too old, please update
CookieMonzteh
CookieMonztehOPβ€’9mo ago
aight lemme try that its 18.0.0 right? nvm i got it v18.19.1 oh my god it didnt work...but I ogt a different error
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
i should just need to install
Brody
Brodyβ€’9mo ago
or maybe i left it out of the backend's package.json by accident
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah its not there lol let me add it
Brody
Brodyβ€’9mo ago
dont add it to the package.json at the root
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah i know, in the backend and front o nes there was 1 or 2 missing in the frontend too but i just copy and pasted it in and npm i should work
Brody
Brodyβ€’9mo ago
lets see your package.json in the root please
CookieMonzteh
CookieMonztehOPβ€’9mo ago
{
"name": "paragon-app",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"frontend:build": "npm run build -w packages/frontend",
"frontend:start": "npm run start -w packages/frontend",
"frontend:dev": "npm run dev -w packages/frontend",
"frontend:test": "npm run test -w packages/frontend",
"backend:start": "npm run start -w packages/backend",
"backend:dev": "npm run dev -w packages/backend"
},
"workspaces": ["./packages/*"]
}
{
"name": "paragon-app",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"frontend:build": "npm run build -w packages/frontend",
"frontend:start": "npm run start -w packages/frontend",
"frontend:dev": "npm run dev -w packages/frontend",
"frontend:test": "npm run test -w packages/frontend",
"backend:start": "npm run start -w packages/backend",
"backend:dev": "npm run dev -w packages/backend"
},
"workspaces": ["./packages/*"]
}
I think it should be working now I just need to fix some file paths i should have asked for your node version earlier πŸ’€ why that solved it is beyond me
Brody
Brodyβ€’9mo ago
node 14 too old
CookieMonzteh
CookieMonztehOPβ€’9mo ago
they say if it aint old dont fix it....they lied
Brody
Brodyβ€’9mo ago
i dont think thats quite how the saying goes
CookieMonzteh
CookieMonztehOPβ€’9mo ago
old, broken, tomatoe tomatoe πŸ˜… gonna take like another 2 minutes prob to fix these files cuzz i remember having to fix them when i split up my repos like this hmmm... question..I need 2 env files in each of these instead of in my root directory dont i?
Brody
Brodyβ€’9mo ago
what are the env files for
CookieMonzteh
CookieMonztehOPβ€’9mo ago
variables like so
app.use(
session(
// secret is used to sign the id session cookie
{
name: "user-session",
resave: false,
saveUninitialized: false,
secret: process.env.SESSION_SECRET,
store: myStorage,
cookie: {
maxAge: 1000 * 60 * 60 * 2,
sameSite: "none",
secure: inProduction
},
}
)
);
app.use(
session(
// secret is used to sign the id session cookie
{
name: "user-session",
resave: false,
saveUninitialized: false,
secret: process.env.SESSION_SECRET,
store: myStorage,
cookie: {
maxAge: 1000 * 60 * 60 * 2,
sameSite: "none",
secure: inProduction
},
}
)
);
Brody
Brodyβ€’9mo ago
then yeah
CookieMonzteh
CookieMonztehOPβ€’9mo ago
aaaaand theres a node_modules folder in my root again for some reason....I think its being carried over from my master branch?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
WHALAAA
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
i dont think its a problem tbh
CookieMonzteh
CookieMonztehOPβ€’9mo ago
i spoke too soon backend is good tho
Brody
Brodyβ€’9mo ago
whats wrong with the frontend
CookieMonzteh
CookieMonztehOPβ€’9mo ago
frontend node modules
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
lemme check something seems like a package issues thats now broken of course. gotta get rdy for work but repo wise its working. After i resolve that and whatever comes up ill lyk when its rdy for deploy. Thanks again fam, not many people will take the time to do this and im learning alot πŸ‘
Brody
Brodyβ€’9mo ago
happy to help!
CookieMonzteh
CookieMonztehOPβ€’9mo ago
gonna fix a few things then I should be good for deploy
CookieMonzteh
CookieMonztehOPβ€’9mo ago
Looks like everythings fine, only error im getting right now is this whenever I go to my landing page
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
other than that it should be good to deploy. im gonna push the changes
Brody
Brodyβ€’9mo ago
haha well what's going on with the manifest?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
from what ive searched up it might have something to do with the index.html file...but again its only for the / landing page * link tag
Brody
Brodyβ€’9mo ago
well see what the manifest response contains easy enough to find out what's going on
CookieMonzteh
CookieMonztehOPβ€’9mo ago
opened up the project to get the error and all the sudden its not showing me that error anywhere when i didnt change anything....
Brody
Brodyβ€’9mo ago
problem solved
CookieMonzteh
CookieMonztehOPβ€’9mo ago
lol right i pushed it to the master branch
Brody
Brodyβ€’9mo ago
deploy to railway time?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ye
Brody
Brodyβ€’9mo ago
show me your current railway project please
CookieMonzteh
CookieMonztehOPβ€’9mo ago
assuming we following the isolated one?https://docs.railway.app/guides/monorepo
Railway Docs
Deploying a Monorepo | Railway Docs
Documentation for Railway
Brody
Brodyβ€’9mo ago
nope
CookieMonzteh
CookieMonztehOPβ€’9mo ago
i got none deleted them all accept the database
Brody
Brodyβ€’9mo ago
okay add a new empty service after every step please send a screenshot so we stay on the correct track
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
this is going to be your backend, so give it an applicable name
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
boring, use capital case and spaces like your database name has
CookieMonzteh
CookieMonztehOPβ€’9mo ago
πŸ˜‚ doesnt it get converted to lowercase? maybe thats the domain lol
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
yeah that's for the domain, add a space on either side of the dash, make the name look presentable
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
okay now we talking now hit deploy, then generate a domain
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
now do all the same, but make a frontend service
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
now what variables does your backend need?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
like 14, just add them now? 1 of the env i need is a frontend url tho which we havent made
Brody
Brodyβ€’9mo ago
the frontend should have a domain by now
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
oh wait u right aight lemme add them then
Brody
Brodyβ€’9mo ago
for FRONTEND_URL you would want to use https://${{AquaPrime - Frontend.RAILWAY_PUBLIC_DOMAIN}} same idea for all the database related variables
Brody
Brodyβ€’9mo ago
use the reference variable i provided please
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
make sure you use the same syntax for your database variables
CookieMonzteh
CookieMonztehOPβ€’9mo ago
mm yeah i see now, imma have to change my code, for some reason I have it to this
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
and the one provided has no dashes
Brody
Brodyβ€’9mo ago
that doesnt matter, you can set your own variable name you dont need to change anything in code also, you would likely want to do a REACT_APP_BACKEND_URL in the same way on your frontend so you can use it in code
CookieMonzteh
CookieMonztehOPβ€’9mo ago
oooh i see what you mean ok
Brody
Brodyβ€’9mo ago
when you're done setting up the variables, show me (hide things that are sensitive though)
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
just making sure thats right ^
Brody
Brodyβ€’9mo ago
yeah looks good to me, after you deploy the changes you would be able to check if they render properly with the given eye icon so when you do finish adding the variables, deploy and then check them with the eye icon
CookieMonzteh
CookieMonztehOPβ€’9mo ago
alright i have one weird one but ill sc only got like 3 more
https://${{AquaPrime - Backend.RAILWAY_PUBLIC_DOMAIN}}/auth/google/oauth2callback
https://${{AquaPrime - Backend.RAILWAY_PUBLIC_DOMAIN}}/auth/google/oauth2callback
Brody
Brodyβ€’9mo ago
what service are you setting that variable on
CookieMonzteh
CookieMonztehOPβ€’9mo ago
which is needed for this
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
its for the oauth google oauth* so its a redirect url after authenticating
Brody
Brodyβ€’9mo ago
what service are you setting that variable on
CookieMonzteh
CookieMonztehOPβ€’9mo ago
you mean on railway? my backend one
Brody
Brodyβ€’9mo ago
if you are referencing a variable from the same service you are setting it on you dont need the service name
https://${{RAILWAY_PUBLIC_DOMAIN}}/auth/google/oauth2callback
https://${{RAILWAY_PUBLIC_DOMAIN}}/auth/google/oauth2callback
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ah got them both done
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
all variables are done?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yep frontend only needed the backend url
Brody
Brodyβ€’9mo ago
we will be deploying the backend code first on the backend service set the start command to npm run backend:start
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
attach your repo then i think thats all, you can then deploy
CookieMonzteh
CookieMonztehOPβ€’9mo ago
same process for frontend im guessing? finishing the backend build first
Brody
Brodyβ€’9mo ago
for the frontend you would need to set npm run frontend:build for the build command and npm run frontend:start for the start command, but lets make sure the backend is operational first
CookieMonzteh
CookieMonztehOPβ€’9mo ago
still waiting, its chonky alright finished, technically didnt fail but alot of errors, I know how to fix a few of them by uncommenting some code I dont think ive seen these errors before tho
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
rebuilding the the code i had commented out in now also I lied it actually did crash on the first build
Brody
Brodyβ€’9mo ago
for this error, in the backend's package.json, set the start script to sleep 3 && node server.js
CookieMonzteh
CookieMonztehOPβ€’9mo ago
got rid of my other errors, gonna try that now building now also...wtf is that sorcery? its like a timeout before running the start script?
Brody
Brodyβ€’9mo ago
yeah?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
howd you think of having to do that? something the error said? race condition? πŸ€”
Brody
Brodyβ€’9mo ago
dns not ready
CookieMonzteh
CookieMonztehOPβ€’9mo ago
what exaclty is this side of development considered? backend? devops? Feels like a whole new realm the moment i put my foot into hosting more complicated sites
Brody
Brodyβ€’9mo ago
i have no clue πŸ™‚
CookieMonzteh
CookieMonztehOPβ€’9mo ago
got the same errors back
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
does your database have a tcp proxy?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
dont even know what that is so ill just say no not that i know of actually? isnt this the same error from yesterday hold on
Brody
Brodyβ€’9mo ago
well no is a bad answer we want a tcp proxy in this case
CookieMonzteh
CookieMonztehOPβ€’9mo ago
oddly eary to this problem we had yesterday I feel like oh?
Brody
Brodyβ€’9mo ago
check if your database has a tcp proxy please
CookieMonzteh
CookieMonztehOPβ€’9mo ago
is it this?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
oh wait i think i know something that might be ruining this too
Brody
Brodyβ€’9mo ago
wdym?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
this
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
forgot to change it should be
app.listen(process.env.PORT || 3001, "0.0.0.0");
app.listen(process.env.PORT || 3001, "0.0.0.0");
not sure if that fixes this specific problem but ik it will causes a problem regardless. building if it fixes it then i could maybe remove that sleep 3 later
Brody
Brodyβ€’9mo ago
maybe
CookieMonzteh
CookieMonztehOPβ€’9mo ago
8+ minute build k so still failed but i think i see the problem one sec
Brody
Brodyβ€’9mo ago
likely because we are installing frontend packages as well as backend packages when deploying the backend
CookieMonzteh
CookieMonztehOPβ€’9mo ago
oh really? thought it would just do the backend ones since we are only using our custom start command, or does it run all the commands from the root package.json? πŸ€” also rebuilding so lets see if its fixed in like 4 minutes
Brody
Brodyβ€’9mo ago
it runs npm ci at the root, meaning it installs everything from both packages, nothing to do the start command
CookieMonzteh
CookieMonztehOPβ€’9mo ago
gotcha
Brody
Brodyβ€’9mo ago
we can fix that
CookieMonzteh
CookieMonztehOPβ€’9mo ago
hmmm odd still get the same error, i went back and lookated the the database environments and the host was weird but i fixed it because i saw a host error but yea still
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
wait i think i see more
Brody
Brodyβ€’9mo ago
what did you fix, there should be no need to fix anything as long as you are using reference variables properly
CookieMonzteh
CookieMonztehOPβ€’9mo ago
it was the db host, had an extra } so im seeing this in there
error when syncing and or running init data
error when syncing and or running init data
so its connecting to the database but for some reason its having an issue with sequalize syncing
sequelize
.sync({ alter: true })
.then(() => {
runInitData();
})
.catch((err) =>
console.log("error when syncing and or running init data", err)
);
sequelize
.sync({ alter: true })
.then(() => {
runInitData();
})
.catch((err) =>
console.log("error when syncing and or running init data", err)
);
gonna try somethings, if you got any ideas feel free to shoot
Brody
Brodyβ€’9mo ago
i do, but let put a pin in that issue for the moment. lets get the separate install commands working
CookieMonzteh
CookieMonztehOPβ€’9mo ago
sounds good
Brody
Brodyβ€’9mo ago
https://github.com/JahnoelRondon/paragon-app/pull/4 your backend will now need a NIXPACKS_CONFIG_FILE variable set to packages/backend/nixpacks.toml set this before you merge the pr
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ah thats for those omit dev errors
Brody
Brodyβ€’9mo ago
no, its so the backend deployment only installs the backend packages
CookieMonzteh
CookieMonztehOPβ€’9mo ago
aight lemme merge it
Brody
Brodyβ€’9mo ago
have you set that variable?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
not yet, do that first?
Brody
Brodyβ€’9mo ago
set this before you merge the pr
CookieMonzteh
CookieMonztehOPβ€’9mo ago
no process.env needed?
Brody
Brodyβ€’9mo ago
this is a service variable what would process.env be used for?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
didnt know if it was something that woudl be used in development but I guess its hosting specific finishing build
Brody
Brodyβ€’9mo ago
show me the build table at the top of the build logs please
CookieMonzteh
CookieMonztehOPβ€’9mo ago
this?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
looks like it worked as for as the command goes
Brody
Brodyβ€’9mo ago
yeah looks good, the new install command is working, are builds faster?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
oh yeah, only took like 2 -3 minutes instead of 8 this time
Brody
Brodyβ€’9mo ago
nice
CookieMonzteh
CookieMonztehOPβ€’9mo ago
got alot of more errors i think though lol
Brody
Brodyβ€’9mo ago
missing some packages prob
CookieMonzteh
CookieMonztehOPβ€’9mo ago
possible that it ran faster because it through out an error faster not sure, but now the connected to database log isnt even there, omit still there and a new uuid import error is there oh wait yeah, cuz i pulled lemme fix them
Brody
Brodyβ€’9mo ago
add uuid to your packages also, dotenv can be moved to dev packages
CookieMonzteh
CookieMonztehOPβ€’9mo ago
this right?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
yes lol
CookieMonzteh
CookieMonztehOPβ€’9mo ago
listen you gotta explain to me like a 4 year old if u havent noticed by now just making sure πŸ˜‚ alright, fixing a few here and redeploying uncommented my function when syncing sequalize as well to make things cleared, should be a minute hmmm, yeah im 99% sure this is a sequalize issue omg πŸ€¦β€β™‚οΈ may have fixed it dont ask πŸ‘€ if it keeps crashing imma do more digging myself then get back to u im just waiting now @Brody fixed it only error i get is npm WARN config production Use --omit=dev instead.
Brody
Brodyβ€’9mo ago
we don't need to worry about that, please ignore so does the backend work? open the domain!
CookieMonzteh
CookieMonztehOPβ€’9mo ago
i mean technically i get this but its supposed to be like that because i dont use a root route but yeah no it works
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
made all my tables and assosioations as well
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
that's awesome, test it with postman? or similar? or do you just wanna deploy your frontend now?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
lemme use postman rq
Brody
Brodyβ€’9mo ago
is your frontend code setup to use that react app backend url variable?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yep for the api urls
Brody
Brodyβ€’9mo ago
for everything? perfect see this isn't too hard as long as you have your project structured correctly
CookieMonzteh
CookieMonztehOPβ€’9mo ago
never even knew there was a right or wrong way lol also that recent pr you made wasnt mandatory right it was just to make builds faster right? gonna seet my data really quick
Brody
Brodyβ€’9mo ago
no not strictly needed, just needed so dependencies aren't cross installed
CookieMonzteh
CookieMonztehOPβ€’9mo ago
still have to study them wepackages and using caddy
Brody
Brodyβ€’9mo ago
you've opened the Caddyfile right?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah but if you ask me i wont remember a thing i kinda glossed over it aight rdy to setup frontend
Brody
Brodyβ€’9mo ago
well you can always look back, it's in plain English and fully self documenting on the frontend you will need a variable NIXPACKS_CONFIG_FILE set to packages/frontend/nixpacks.toml your build command will be npm run frontend:build and your start command will be npm run frontend:start
CookieMonzteh
CookieMonztehOPβ€’9mo ago
and connect my repo or just deploy first?
Brody
Brodyβ€’9mo ago
yeah you can connect your repo too and then deploy all the changes in one go unless im forgetting something, but i guess we shall find that out
CookieMonzteh
CookieMonztehOPβ€’9mo ago
deploying i need to save our convo somehow by the time this is done, taking notes like sanat clause
Brody
Brodyβ€’9mo ago
its not going anywhere
CookieMonzteh
CookieMonztehOPβ€’9mo ago
also i just realized but when i update the repo both of them will redeploy
Brody
Brodyβ€’9mo ago
yeah you can use watchpaths for that
CookieMonzteh
CookieMonztehOPβ€’9mo ago
like in their respective nixpacks? quickly glossing over it while i fix deploy issues
Brody
Brodyβ€’9mo ago
in the service settings
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ah
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
no clue tbh, ive never used that feature, you will have to play around
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah ill give it a go afterwards alright
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
something we missed in settings maybe?
Brody
Brodyβ€’9mo ago
why do you say that?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
guessing tbh saying things arent disabled are disabled *
Brody
Brodyβ€’9mo ago
we dont want caddy to do https, railway handles that admin endopoint is also useless
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ah so these arent a concern domain is working soab its back the manifest, lemme check it
Brody
Brodyβ€’9mo ago
send link?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
also i have to change some settings in my google cloud console since its in production now one sec
CookieMonzteh
CookieMonztehOPβ€’9mo ago
React App
Web site created using create-react-app
CookieMonzteh
CookieMonztehOPβ€’9mo ago
alright
Brody
Brodyβ€’9mo ago
i got the manifest error, but then i did a hard refresh and the error went away
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah same, idk what thats about
Brody
Brodyβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
blame cache
CookieMonzteh
CookieMonztehOPβ€’9mo ago
doesnt seem to break anything deploy is fine but still having some issues that imma see if I can refix rq resetting client secrets and a bunch of other stuff so this will take a while
CookieMonzteh
CookieMonztehOPβ€’9mo ago
Alright so I gave it like half a day in terms of hours to make sure, as far as deploying goes Im 99% sure its fine...but now im back to square one with my original problem with sessions.
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
when i check the database sessions are being made
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
from this code
// SESSIONS
// When hosting we have to drop expresses way of session storage (store) since it stores it in memory and causes memory leaks and our memeory is finite.
const SequelizeStorage = SequelizeStore(session.Store)
const myStorage = new SequelizeStorage({
db: sequelize
})

// This env variable would only exist on hosted services and not local dev
let inProduction = process.env.NODE_ENV === "production"

app.use(
session(
// secret is used to sign the id session cookie
{
name: "user-session",
resave: false,
saveUninitialized: false,
secret: process.env.SESSION_SECRET,
store: myStorage,
cookie: {
maxAge: 1000 * 60 * 60 * 2,
sameSite: "none",
secure: inProduction
},
}
)
);
// SESSIONS
// When hosting we have to drop expresses way of session storage (store) since it stores it in memory and causes memory leaks and our memeory is finite.
const SequelizeStorage = SequelizeStore(session.Store)
const myStorage = new SequelizeStorage({
db: sequelize
})

// This env variable would only exist on hosted services and not local dev
let inProduction = process.env.NODE_ENV === "production"

app.use(
session(
// secret is used to sign the id session cookie
{
name: "user-session",
resave: false,
saveUninitialized: false,
secret: process.env.SESSION_SECRET,
store: myStorage,
cookie: {
maxAge: 1000 * 60 * 60 * 2,
sameSite: "none",
secure: inProduction
},
}
)
);
however I feel like im missing something. This is essentially the catalyst of my problem. This is kind of where i was when I initially started and had my repos split up before we started definitely feel like im missing something but ive just followed as much of the docs as i could as well as research on cookie / sessions settings to make this work. :bladerunner: actually now that I think about it this is the part where everyone was telling me to setup a proxy to resolve this issue and I think we havent set that up yet πŸ€” switched to a dev environment where i commented these out for local host and it works
app.use(
session(
// secret is used to sign the id session cookie
{
name: "user-session",
// resave: false,
// saveUninitialized: false,
secret: process.env.SESSION_SECRET,
// store: myStorage,
// cookie: {
// maxAge: 1000 * 60 * 60 * 2,
// sameSite: "none",
// secure: inProduction
// },
}
)
);
app.use(
session(
// secret is used to sign the id session cookie
{
name: "user-session",
// resave: false,
// saveUninitialized: false,
secret: process.env.SESSION_SECRET,
// store: myStorage,
// cookie: {
// maxAge: 1000 * 60 * 60 * 2,
// sameSite: "none",
// secure: inProduction
// },
}
)
);
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
found this post. I feel like this can be done without a proxy and its just a matter of me missing pieces to this puzzle, Ive had a feeling like I should be able to send a cookie to the browser manually when creating or retreiving a user but idk
CookieMonzteh
CookieMonztehOPβ€’9mo ago
Stack Overflow
Express-session is not setting cookies in browser
So I'm using express-session package to set cookie and session. It's also connected to my MongoDB store to store session. When user logs in, session gets stored in database just fine but there's no
Brody
Brodyβ€’9mo ago
you have to remember that your app sits behind a proxy on railway, your app runs in http mode, so it doesn't like setting secure cookies when running in http mode, you want to find a way to let it know that it's indeed being accessed from https, this is usually done by trusting the proxy headers that railway sets in this case, specifically the X-Forwarded-Proto that railway sets to https
CookieMonzteh
CookieMonztehOPβ€’9mo ago
so its railways proxy thats blocking the cookies not my code?
Brody
Brodyβ€’9mo ago
no no it's not blocking anything, I'm not sure how you came to that conclusion
CookieMonzteh
CookieMonztehOPβ€’9mo ago
well if the proxy wasnt there then it would just be normal https no? which is why it works on local host and not railway because of the proxy? πŸ€” so I have to set X-Forwarded-Protocol: https in the headers? πŸ€”
Brody
Brodyβ€’9mo ago
no, and no
CookieMonzteh
CookieMonztehOPβ€’9mo ago
this is where my lack of proxy knowledge is showing
Brody
Brodyβ€’9mo ago
no proxy knowledge needed, railway sets that header for you, you just need to trust it's value you are trying to set secure cookies. your app will not set the secure cookies when it thinks it's being accessed over http. trust the X-Forwarded-Proto header that's set to https. now your app thinks it's being accessed over https. now you can set secure cookies.
CookieMonzteh
CookieMonztehOPβ€’9mo ago
aaah ok, that makes a bit more sense now. I just assumed it would be https autamtically because its a hosted domain
Brody
Brodyβ€’9mo ago
it is https externally, but express doesn't know that unless it trusts the header express has a really nice guide https://expressjs.com/en/guide/behind-proxies.html
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
CookieMonzteh
CookieMonztehOPβ€’9mo ago
mmmm ok, it kinda reminds me of cors how you have to specify the domain but in this case you specify that its https and from where πŸ€”
Brody
Brodyβ€’9mo ago
not quite
CookieMonzteh
CookieMonztehOPβ€’9mo ago
is the proxy service specific?
Brody
Brodyβ€’9mo ago
wdym?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
like would it be from the frontend service or backend service? or is there a universal proxy for railway that everyone uses?
Brody
Brodyβ€’9mo ago
every service that's accessed externally will use a proxy your frontend already handles this, look into the Caddyfile and there's a line about trusting the proxy though that is strictly only so you get the correct client IP in the logs, nothing more
CookieMonzteh
CookieMonztehOPβ€’9mo ago
doing some reading rq
Brody
Brodyβ€’9mo ago
just look at the link I sent
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah thats what im trying to understand πŸ’€ . the main takeaways im understanding is that it changes/adds onto the request about details from the external service?
Brody
Brodyβ€’9mo ago
from the actual request the client made, yes
CookieMonzteh
CookieMonztehOPβ€’9mo ago
so in that case then what? after setting that up which im kinda now understanding is for any external thing we just do conditionals in our code checking if its railway?
Brody
Brodyβ€’9mo ago
maybe this will give you a good visual? https://utilities.up.railway.app/raw this endpoint echoes back all the http headers that the app sees during a request why do you need code to check if it's Railway, trust the proxy and then set your secure cookies and job done (hopefully) I think you're over complicating and over thinking this
CookieMonzteh
CookieMonztehOPβ€’9mo ago
probably πŸ˜‚ , mind is trying to make sense of what looks like gibberish rn. i guess the one thing thats a bit confusing to me is this code even after reading the docs but might just take some time and doing rathern than reading lemme set that up
Brody
Brodyβ€’9mo ago
it trusts the headers the proxy sets, but it only trusts the headers if they where set by a local IP address
CookieMonzteh
CookieMonztehOPβ€’9mo ago
imma stick with that explanation and read more after πŸ˜‚ , trust me you're explaining it perfectly its just gonna take me a second. its building rn so lets cross fingers 🀞 I think thats the money emoji lol
Brody
Brodyβ€’9mo ago
close enough
CookieMonzteh
CookieMonztehOPβ€’9mo ago
question while this builds but, is this the norm with most services when hosting? that they sit behind a proxy of that service? liek if i was using vercel or fly.io they would sit behind one or is that just something you have to do your research on? asking because i would have never gotten this on my own and idk if its common knowledge
Brody
Brodyβ€’9mo ago
yes every similar service would use a proxy, without a proxy there would be no way for the platform to route incoming traffic to the correct deployment
CookieMonzteh
CookieMonztehOPβ€’9mo ago
for some reason there seems to be liek this limited amount of resources for this ive felt like but maybe thats just me, any answer id look up would just talk about cookie configs or sessions but never proxies ok that makes everything 100% more clearer thanks πŸ‘
Brody
Brodyβ€’9mo ago
express is just being picky
Brody
Brodyβ€’9mo ago
picky, but makes sense
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
you dont understand when i say....ive spent weeks just trying to see this πŸ˜‚
Brody
Brodyβ€’9mo ago
deployment is easy once you have your code in order and understand how the platform works
CookieMonzteh
CookieMonztehOPβ€’9mo ago
bru hand thats the part that scares me, you really have to invest in your hosting service like no other and railway makes alot of things easy for you so imagine fly.io πŸ’€ . coming from using netlify for static sites and comparing it i didnt think this would be the beast that it is but you can correct me if im wrong but im asssuming this is like everything else (language, framework), but after you learn one well enough you kinda understand how to work with others. This is my first time rlly working with a hosting service like this. Definitely made it look easy though. I got so much studying and looking over after this, thanks a thousand man ❀️ unironically I think that adding that one line of code you showed me at the end might have solved my issue when I had it setup the way I did but the structure you showed me is invaluable too πŸ‘
Brody
Brodyβ€’9mo ago
yeah railway definitely has more of a learning curve than something like netlify, but that's just because you can run so much more on railway, and that's in part why railway doesn't just figure it out for you, because the scope of what railway can host is far too broad
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah thats why i always assumed πŸ˜‚ but after doing all this it makes sense because its made to be flexible
Brody
Brodyβ€’9mo ago
exactly, railway is flexible, that's why you need to provide a way for railway to properly host the frontend site, by getting it to install caddy and have caddy actually serve the built site files
CookieMonzteh
CookieMonztehOPβ€’9mo ago
im probably just gonna look and stare at this screen in aw for a few minutes. πŸ˜‚ , I have some questions about my sesson store but imma wait on that and make a seperate post cuz i wanna soak all this in.
Brody
Brodyβ€’9mo ago
but accidentally running a development server on railway is something that is incredibly common, and unfortunately if left unchecked would end up in a $5+ bill just for the frontend service that's around 600mb of ram, and what's your frontend using? sub 20mb?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
yeah thats another side of it too that I have to learn. Is there a doc or forum you follow that tells you things like this as far as cost effectiveness for hosting services? πŸ€”
Brody
Brodyβ€’9mo ago
more so about a rule of thumb, don't run development servers but the alternatives are a case by case basis, and I only have experience with caddy
CookieMonzteh
CookieMonztehOPβ€’9mo ago
ah, makes sense.
Brody
Brodyβ€’9mo ago
caddy for website hosting is definitely the most user friendly, so it works quite well
CookieMonzteh
CookieMonztehOPβ€’9mo ago
I guess you can fiddle with some stuff to and track your usage
Brody
Brodyβ€’9mo ago
have you checked out the metrics service tabs?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
nope lol I havent had a need to because ive had nothing in my project other than the database usually, am now tho
CookieMonzteh
CookieMonztehOPβ€’9mo ago
No description
CookieMonzteh
CookieMonztehOPβ€’9mo ago
outbound?
Brody
Brodyβ€’9mo ago
yeah what about it?
CookieMonzteh
CookieMonztehOPβ€’9mo ago
shouldnt the network be inbound because the backends on railway? or am i reading that wrong :thonk: stuff like that i guess imma have to learn to
Brody
Brodyβ€’9mo ago
network traffic goes both ways, in and out
CookieMonzteh
CookieMonztehOPβ€’9mo ago
gotcha imma take a quick break and then start studying this and messing with the application. Im not a wiz yet but if you need to learn how to make a mean chicken stew im your guy πŸ‘ 😎
Brody
Brodyβ€’9mo ago
I like chicken
Want results from more Discord servers?
Add your server