Deploying Shared Mono Repo confusion
Anonymous
TRIALOP

2 years ago

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"
  },

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 🙏

571 Replies

Anonymous
TRIALOP

2 years ago

87f56f88-5de7-4a88-8ed9-9e3f3af4ea9f


Anonymous
TRIALOP

2 years ago

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
EMPLOYEE

2 years 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.


brody
EMPLOYEE

2 years ago

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.



Anonymous
TRIALOP

2 years ago

the whole reason i went back to using my mono repo was so i didnt have to do this 🤦‍♂️


Anonymous
TRIALOP

2 years ago

ive been working for weeks trying to get my project thats pretty much already done hosted and its been such a nightmare


brody
EMPLOYEE

2 years ago

two apps need two railway services


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

there is, but your frontend and backend are two apps, even if they share types, so they need two services


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

yeah you still need two services for that, we can setup a proxy if thats what you would like


brody
EMPLOYEE

2 years ago


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years 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


brody
EMPLOYEE

2 years ago

the link is what your project should look like (maybe minus a database)


brody
EMPLOYEE

2 years ago

(i have a template for the proxy)


Anonymous
TRIALOP

2 years 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.


Anonymous
TRIALOP

2 years ago

he suggested that its still possible on railway via docker config? 🤔


Anonymous
TRIALOP

2 years ago

"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
EMPLOYEE

2 years ago

yes you can have your backend serve the frontend, that is certainly one way, personally its not something i would do


Anonymous
TRIALOP

2 years ago

yeah i mean im kinda out of options man 🤷


Anonymous
TRIALOP

2 years ago

so i kinda have to try something else


Anonymous
TRIALOP

2 years ago

because doing it that way hasnt worked for me and I dont know why so doing this is at least progress towards something


brody
EMPLOYEE

2 years ago

three options

  • two railway services

  • two railway services + a proxy

  • one service - serve the frontend from the backend


Anonymous
TRIALOP

2 years ago

i wouldnt either tho


brody
EMPLOYEE

2 years ago

you pick, ill help with whatever you pick


Anonymous
TRIALOP

2 years ago

alright so lets do this then


brody
EMPLOYEE

2 years ago

what option?


Anonymous
TRIALOP

2 years ago

2.)


brody
EMPLOYEE

2 years ago

good choice


Anonymous
TRIALOP

2 years ago

question tho


brody
EMPLOYEE

2 years ago

of course


Anonymous
TRIALOP

2 years 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?


Anonymous
TRIALOP

2 years ago

lemme send the link


brody
EMPLOYEE

2 years ago

did you want to keep the frontend on netlify?


Anonymous
TRIALOP

2 years ago

87f56f88-5de7-4a88-8ed9-9e3f3af4ea9f


Anonymous
TRIALOP

2 years ago

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


Anonymous
TRIALOP

2 years ago

if switching it makes things easier…then no


brody
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years 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


Anonymous
TRIALOP

2 years ago

in that case yeah i can have it on railway


brody
EMPLOYEE

2 years ago

it would also have far more latency


brody
EMPLOYEE

2 years ago

egress is the amount of data out of the network


Anonymous
TRIALOP

2 years ago

interesting, guess that makes sense. I thought storage would have cost more but goes to show how little i know lol


Anonymous
TRIALOP

2 years ago

im setting it up rn


brody
EMPLOYEE

2 years ago

the frontend doesn't use any charge-able storage on railway


brody
EMPLOYEE

2 years ago

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


brody
EMPLOYEE

2 years ago

we want to save money here not burn it


brody
EMPLOYEE

2 years ago

the less resources your services use, the cheaper they are to run


Anonymous
TRIALOP

2 years ago

oh yeah you mentioned alot of stuff earlier about not using nodemon and whatnot


brody
EMPLOYEE

2 years ago

share or add me to your repo and I'll see what changes need to be made


Anonymous
TRIALOP

2 years ago

sry if i didnt catch everything i was talking back and forth with someone


Anonymous
TRIALOP

2 years ago

which one?


brody
EMPLOYEE

2 years ago

no worries


Anonymous
TRIALOP

2 years ago

both?


brody
EMPLOYEE

2 years ago

you have a mono repo, it is only one repo? wdym both?


Anonymous
TRIALOP

2 years ago

also this channel doesnt have vc?


brody
EMPLOYEE

2 years ago

nope, no VC needed


Anonymous
TRIALOP

2 years 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?


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

yeah that's quite convoluted, you should remove those two repos designated backend and frontend


Anonymous
TRIALOP

2 years ago

gotcha


brody
EMPLOYEE

2 years ago

then add me to the first repo, my gh username is brody192


brody
EMPLOYEE

2 years ago

unless it's public, in that case just send the link


Anonymous
TRIALOP

2 years ago

added


brody
EMPLOYEE

2 years ago

looking


Anonymous
TRIALOP

2 years ago

no worries, im looking over stuff to and trying to make it work again in local dev


brody
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

well this repo is technically a monorepo, its mushed together, this makes both it hard to run both locally and on railway


Anonymous
TRIALOP

2 years ago

I thought that was supposed to make things easier?


brody
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years ago

ah thats what you meant. gotcha


brody
EMPLOYEE

2 years ago

ill try my hand at a pr to get this repo in shape


Anonymous
TRIALOP

2 years ago

sounds good. thank you 🙏


Anonymous
TRIALOP

2 years ago

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
EMPLOYEE

2 years ago

sounds good


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

I just googled how to setup a npm workspace haha


brody
EMPLOYEE

2 years ago

did you see my branch?


Anonymous
TRIALOP

2 years ago

ah, yeah i see it now


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

yep thats it


brody
EMPLOYEE

2 years ago

okay so do you wanna walk through how to deploy my branch?


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

sounds good


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

Yeah i was assuming that too, still thanks 1000X


Anonymous
TRIALOP

2 years ago

might have some quick questions as I read


brody
EMPLOYEE

2 years ago

of course


Anonymous
TRIALOP

2 years ago

for example the

"workspaces": ["./packages/*"]

is just return an array of both folder paths? so its essentially a shorter version of?

"workspaces": ["./packages/frontend", "./packages/backend"]

Anonymous
TRIALOP

2 years ago

im assuming the * just means return all files


brody
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years 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?


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

"start": "caddy run", ?


Anonymous
TRIALOP

2 years ago

railway specific files and scripts?


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

wow


Anonymous
TRIALOP

2 years ago

how in the world do you know this 💀


brody
EMPLOYEE

2 years ago

this isn't my first rodeo


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

you can think of caddy as a file server, nothing to do with node. its simply serving the built website files



Anonymous
TRIALOP

2 years ago

definitely will do more research on it but I think i get the jist


Anonymous
TRIALOP

2 years ago

imma test out the repo rn


brody
EMPLOYEE

2 years ago

locally?


Anonymous
TRIALOP

2 years ago

ye


brody
EMPLOYEE

2 years ago

okay cool, there is a procedure to deploy onto railway, so let me know when you wanna do that


Anonymous
TRIALOP

2 years ago

sounds good thank you 🙏


Anonymous
TRIALOP

2 years ago

just attempted running it and I think the root package.json file needs a start script


brody
EMPLOYEE

2 years ago

nope


brody
EMPLOYEE

2 years ago

npm run frontend:dev
and
npm run backend:dev


Anonymous
TRIALOP

2 years ago

ahhhh i was doing :start mb


Anonymous
TRIALOP

2 years ago

hmmm


Anonymous
TRIALOP

2 years ago

yeah thats weird i get the same error


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

when i used :start it said the same thing


brody
EMPLOYEE

2 years ago

please see the commands i have sent here


Anonymous
TRIALOP

2 years ago

yeah those are what I put


Anonymous
TRIALOP

2 years ago

copy and pasted and everything


Anonymous
TRIALOP

2 years ago

I meant i get the same error except instead of start its combplaining about the dev


brody
EMPLOYEE

2 years ago

did you change anything? it works for me


Anonymous
TRIALOP

2 years ago

nope, do i need to npm init maybe?


brody
EMPLOYEE

2 years ago

nope, it just works for me, show me your package.json from your backend


Anonymous
TRIALOP

2 years 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"
  }
}

brody
EMPLOYEE

2 years ago

can you run start


brody
EMPLOYEE

2 years ago

you are running that command from the root right?


Anonymous
TRIALOP

2 years ago

yep, you can see the command and the directory in the sc, i tried both start and dev and get that error


Anonymous
TRIALOP

2 years ago

lemme try something


Anonymous
TRIALOP

2 years ago

tried npm installing to make sure and restarded and yep i still get them,


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

I doubt it was the way I fetched the branch


Anonymous
TRIALOP

2 years ago

might be this



Anonymous
TRIALOP

2 years ago

imma see if i can figure it out but i think its most likely something do do with this


brody
EMPLOYEE

2 years ago

it still works for me locally, something is misconfigured on your end, try deleting and redownloading the branch


Anonymous
TRIALOP

2 years ago

only other solution im seeing is to delete my node modules and resinstall


brody
EMPLOYEE

2 years ago

cant hurt to try


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

😂 i dont lol


brody
EMPLOYEE

2 years ago

lmao


Anonymous
TRIALOP

2 years ago

just noticed something different but could you screen shot what your root directory looks like


Anonymous
TRIALOP

2 years ago

this is mine now


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

what version of node are you using


brody
EMPLOYEE

2 years ago


Anonymous
TRIALOP

2 years 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


Anonymous
TRIALOP

2 years ago

I looked in here too


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

have you tried this?


Anonymous
TRIALOP

2 years ago

yep


Anonymous
TRIALOP

2 years ago

even vscode is asking me wtf im doing


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

i saw that too


Anonymous
TRIALOP

2 years ago

just so we are on the same page….git checkout -t origin/branch-name is what im doing for that branch?


Anonymous
TRIALOP

2 years ago

i might just make a completely seperate local repo and clonse it just to make sure


brody
EMPLOYEE

2 years ago

i dont know, i dont use git cli


Anonymous
TRIALOP

2 years ago

imma bout to fight my computer lol, lemme try cloning on a clean repo


Anonymous
TRIALOP

2 years ago

nvm thats not a thing you can do in git



Anonymous
TRIALOP

2 years ago

yeah no you can only clone from the master branch and get the branches through it


brody
EMPLOYEE

2 years ago

what node verison are you using


Anonymous
TRIALOP

2 years ago

i was actually about to ask the same thing earlier. 14.17.0


Anonymous
TRIALOP

2 years ago

im like 99% sure this is a node issue


brody
EMPLOYEE

2 years ago

im on 18 lts
14 is far too old, please update


Anonymous
TRIALOP

2 years ago

aight lemme try that


Anonymous
TRIALOP

2 years ago

its 18.0.0 right?


Anonymous
TRIALOP

2 years ago

nvm i got it v18.19.1


Anonymous
TRIALOP

2 years ago

oh my god


Anonymous
TRIALOP

2 years ago

it didnt work…but I ogt a different error


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

i should just need to install


brody
EMPLOYEE

2 years ago

or maybe i left it out of the backend's package.json by accident


Anonymous
TRIALOP

2 years ago

yeah its not there lol


Anonymous
TRIALOP

2 years ago

let me add it


brody
EMPLOYEE

2 years ago

dont add it to the package.json at the root


Anonymous
TRIALOP

2 years ago

yeah i know, in the backend and front o nes


Anonymous
TRIALOP

2 years ago

there was 1 or 2 missing in the frontend too but i just copy and pasted it in and npm i should work


brody
EMPLOYEE

2 years ago

lets see your package.json in the root please


Anonymous
TRIALOP

2 years 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/*"]
}

Anonymous
TRIALOP

2 years ago

I think it should be working now I just need to fix some file paths


Anonymous
TRIALOP

2 years ago

i should have asked for your node version earlier 💀 why that solved it is beyond me


brody
EMPLOYEE

2 years ago

node 14 too old


Anonymous
TRIALOP

2 years ago

they say if it aint old dont fix it….they lied



brody
EMPLOYEE

2 years ago

i dont think thats quite how the saying goes


Anonymous
TRIALOP

2 years ago

old, broken, tomatoe tomatoe 😅


Anonymous
TRIALOP

2 years ago

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


Anonymous
TRIALOP

2 years ago

hmmm… question..I need 2 env files in each of these instead of in my root directory dont i?


brody
EMPLOYEE

2 years ago

what are the env files for


Anonymous
TRIALOP

2 years ago

variables like so


Anonymous
TRIALOP

2 years ago

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
EMPLOYEE

2 years ago

then yeah


Anonymous
TRIALOP

2 years ago

aaaaand theres a node_modules folder in my root again for some reason….I think its being carried over from my master branch?


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

WHALAAA


Anonymous
TRIALOP

2 years ago



brody
EMPLOYEE

2 years ago

i dont think its a problem tbh


Anonymous
TRIALOP

2 years ago

i spoke too soon


Anonymous
TRIALOP

2 years ago

backend is good tho


brody
EMPLOYEE

2 years ago

whats wrong with the frontend


Anonymous
TRIALOP

2 years ago

frontend node modules


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

lemme check something


Anonymous
TRIALOP

2 years ago

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
EMPLOYEE

2 years ago

happy to help!


Anonymous
TRIALOP

2 years ago

alright so I fixed it and both the frontend and backend now work…now im back where I started as far as my original issue…and thats my sessions not saving…im going to go ahead and say this is probably why


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

google doing bs


Anonymous
TRIALOP

2 years ago

doing it on firefox doesnt work either so it could not be this


Anonymous
TRIALOP

2 years ago

or….is this where a proxy would solve it?


Anonymous
TRIALOP

2 years ago

imma setup one to see


Anonymous
TRIALOP

2 years ago

nvm….finally got it it looks like


Anonymous
TRIALOP

2 years ago

gonna fix a few things then I should be good for deploy


Anonymous
TRIALOP

2 years ago

Looks like everythings fine, only error im getting right now is this whenever I go to my landing page


Anonymous
TRIALOP

2 years ago

other than that it should be good to deploy. im gonna push the changes


brody
EMPLOYEE

2 years ago

haha well what's going on with the manifest?



Anonymous
TRIALOP

2 years 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


Anonymous
TRIALOP

2 years ago

  • link tag


brody
EMPLOYEE

2 years ago

well see what the manifest response contains


brody
EMPLOYEE

2 years ago

easy enough to find out what's going on


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

problem solved


Anonymous
TRIALOP

2 years ago

lol right


Anonymous
TRIALOP

2 years ago

i pushed it to the master branch


brody
EMPLOYEE

2 years ago

deploy to railway time?


Anonymous
TRIALOP

2 years ago

ye


brody
EMPLOYEE

2 years ago

show me your current railway project please


Anonymous
TRIALOP

2 years ago

assuming we following the isolated one?https://docs.railway.app/guides/monorepo


brody
EMPLOYEE

2 years ago

nope


Anonymous
TRIALOP

2 years ago

i got none


Anonymous
TRIALOP

2 years ago

deleted them all accept the database


brody
EMPLOYEE

2 years ago

okay add a new empty service


brody
EMPLOYEE

2 years ago

after every step please send a screenshot so we stay on the correct track


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

this is going to be your backend, so give it an applicable name


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

boring, use capital case and spaces like your database name has


Anonymous
TRIALOP

2 years ago

😂 doesnt it get converted to lowercase? maybe thats the domain lol


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

yeah that's for the domain, add a space on either side of the dash, make the name look presentable


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

okay now we talking


brody
EMPLOYEE

2 years ago

now hit deploy, then generate a domain


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

now do all the same, but make a frontend service


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

now what variables does your backend need?


Anonymous
TRIALOP

2 years ago

like 14, just add them now?


Anonymous
TRIALOP

2 years ago

1 of the env i need is a frontend url tho which we havent made


brody
EMPLOYEE

2 years ago

the frontend should have a domain by now


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

oh wait u right


Anonymous
TRIALOP

2 years ago

aight lemme add them then


brody
EMPLOYEE

2 years ago

for FRONTEND_URL you would want to use [https://${{AquaPrime](https://${{AquaPrime) - Frontend.RAILWAY_PUBLIC_DOMAIN}}


brody
EMPLOYEE

2 years ago

same idea for all the database related variables


Anonymous
TRIALOP

2 years ago

would this work?



brody
EMPLOYEE

2 years ago

use the reference variable i provided please


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

make sure you use the same syntax for your database variables


Anonymous
TRIALOP

2 years ago

mm yeah i see now, imma have to change my code, for some reason I have it to this


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

and the one provided has no dashes


brody
EMPLOYEE

2 years ago

that doesnt matter, you can set your own variable name


brody
EMPLOYEE

2 years ago

you dont need to change anything in code


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

oooh i see what you mean ok


brody
EMPLOYEE

2 years ago

when you're done setting up the variables, show me (hide things that are sensitive though)


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

just making sure thats right ^


brody
EMPLOYEE

2 years 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


brody
EMPLOYEE

2 years ago

so when you do finish adding the variables, deploy and then check them with the eye icon


Anonymous
TRIALOP

2 years ago

alright


Anonymous
TRIALOP

2 years ago

i have one weird one but ill sc only got like 3 more


Anonymous
TRIALOP

2 years ago

```https://${{AquaPrime - Backend.RAILWAYPUBLICDOMAIN}}/auth/google/oauth2callback

```


brody
EMPLOYEE

2 years ago

what service are you setting that variable on


Anonymous
TRIALOP

2 years ago

which is needed for this


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

its for the oauth


Anonymous
TRIALOP

2 years ago

google oauth*


Anonymous
TRIALOP

2 years ago

so its a redirect url after authenticating


brody
EMPLOYEE

2 years ago

what service are you setting that variable on


Anonymous
TRIALOP

2 years ago

you mean on railway? my backend one


brody
EMPLOYEE

2 years 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

Anonymous
TRIALOP

2 years ago

ah


Anonymous
TRIALOP

2 years ago

got them both done


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

all variables are done?


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

yep


Anonymous
TRIALOP

2 years ago

frontend only needed the backend url


brody
EMPLOYEE

2 years ago

we will be deploying the backend code first


brody
EMPLOYEE

2 years ago

on the backend service set the start command to npm run backend:start


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

attach your repo


brody
EMPLOYEE

2 years ago

then i think thats all, you can then deploy


Anonymous
TRIALOP

2 years ago

same process for frontend im guessing?


Anonymous
TRIALOP

2 years ago

finishing the backend build first


brody
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years ago

still waiting, its chonky


Anonymous
TRIALOP

2 years ago

alright


Anonymous
TRIALOP

2 years ago

finished, technically didnt fail but alot of errors, I know how to fix a few of them by uncommenting some code


Anonymous
TRIALOP

2 years ago

I dont think ive seen these errors before tho


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

rebuilding the the code i had commented out in now


Anonymous
TRIALOP

2 years ago

also I lied it actually did crash on the first build


brody
EMPLOYEE

2 years ago

for this error, in the backend's package.json, set the start script to sleep 3 && node server.js


Anonymous
TRIALOP

2 years ago

got rid of my other errors, gonna try that now


Anonymous
TRIALOP

2 years ago

building now


Anonymous
TRIALOP

2 years ago

also…wtf is that sorcery? its like a timeout before running the start script?


brody
EMPLOYEE

2 years ago

yeah?


Anonymous
TRIALOP

2 years ago

howd you think of having to do that? something the error said? race condition? 🤔


brody
EMPLOYEE

2 years ago

dns not ready


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

i have no clue 🙂


Anonymous
TRIALOP

2 years ago

got the same errors back


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

does your database have a tcp proxy?


Anonymous
TRIALOP

2 years ago

dont even know what that is so ill just say no


Anonymous
TRIALOP

2 years ago

not that i know of


Anonymous
TRIALOP

2 years ago

actually?


Anonymous
TRIALOP

2 years ago

isnt this the same error from yesterday


Anonymous
TRIALOP

2 years ago

hold on


brody
EMPLOYEE

2 years ago

well no is a bad answer


brody
EMPLOYEE

2 years ago

we want a tcp proxy in this case


Anonymous
TRIALOP

2 years ago

oddly eary to this problem we had yesterday I feel like


Anonymous
TRIALOP

2 years ago

oh?


brody
EMPLOYEE

2 years ago

check if your database has a tcp proxy please


Anonymous
TRIALOP

2 years ago

is it this?


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

oh wait


Anonymous
TRIALOP

2 years ago

i think i know something that might be ruining this too


brody
EMPLOYEE

2 years ago

wdym?


Anonymous
TRIALOP

2 years ago

this


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

forgot to change it


Anonymous
TRIALOP

2 years ago

should be app.listen(process.env.PORT || 3001, "0.0.0.0");


Anonymous
TRIALOP

2 years ago

not sure if that fixes this specific problem but ik it will causes a problem regardless.


Anonymous
TRIALOP

2 years ago

building


Anonymous
TRIALOP

2 years ago

if it fixes it then i could maybe remove that sleep 3 later


brody
EMPLOYEE

2 years ago

maybe


Anonymous
TRIALOP

2 years ago

8+ minute build


Anonymous
TRIALOP

2 years ago

k so still failed but i think i see the problem one sec


brody
EMPLOYEE

2 years ago

likely because we are installing frontend packages as well as backend packages when deploying the backend


Anonymous
TRIALOP

2 years 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? 🤔


Anonymous
TRIALOP

2 years ago

also rebuilding so lets see if its fixed in like 4 minutes


brody
EMPLOYEE

2 years ago

it runs npm ci at the root, meaning it installs everything from both packages, nothing to do the start command


Anonymous
TRIALOP

2 years ago

gotcha


brody
EMPLOYEE

2 years ago

we can fix that


Anonymous
TRIALOP

2 years ago

hmmm


Anonymous
TRIALOP

2 years ago

odd


Anonymous
TRIALOP

2 years ago

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


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

wait


Anonymous
TRIALOP

2 years ago

i think i see more


brody
EMPLOYEE

2 years ago

what did you fix, there should be no need to fix anything as long as you are using reference variables properly


Anonymous
TRIALOP

2 years ago

it was the db host, had an extra }


Anonymous
TRIALOP

2 years ago

so im seeing this in there


Anonymous
TRIALOP

2 years ago

error when syncing and or running init data


Anonymous
TRIALOP

2 years ago

so its connecting to the database but for some reason its having an issue with sequalize syncing


Anonymous
TRIALOP

2 years ago

  sequelize
    .sync({ alter: true })
    .then(() => {
      runInitData();
    })
    .catch((err) =>
      console.log("error when syncing and or running init data", err)
    );

Anonymous
TRIALOP

2 years ago

gonna try somethings, if you got any ideas feel free to shoot


brody
EMPLOYEE

2 years ago

i do, but let put a pin in that issue for the moment. lets get the separate install commands working


Anonymous
TRIALOP

2 years ago

sounds good


brody
EMPLOYEE

2 years ago


brody
EMPLOYEE

2 years ago

your backend will now need a NIXPACKS_CONFIG_FILE variable set to packages/backend/nixpacks.toml
set this before you merge the pr


Anonymous
TRIALOP

2 years ago

ah thats for those omit dev errors


brody
EMPLOYEE

2 years ago

no, its so the backend deployment only installs the backend packages



Anonymous
TRIALOP

2 years ago

aight lemme merge it


brody
EMPLOYEE

2 years ago

have you set that variable?


Anonymous
TRIALOP

2 years ago

not yet, do that first?


brody
EMPLOYEE

2 years ago

set this before you merge the pr


Anonymous
TRIALOP

2 years ago

no process.env needed?


brody
EMPLOYEE

2 years ago

this is a service variable


brody
EMPLOYEE

2 years ago

what would process.env be used for?


Anonymous
TRIALOP

2 years ago

didnt know if it was something that woudl be used in development but I guess its hosting specific


Anonymous
TRIALOP

2 years ago

finishing build


brody
EMPLOYEE

2 years ago

show me the build table at the top of the build logs please


Anonymous
TRIALOP

2 years ago

this?


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

looks like it worked as for as the command goes


brody
EMPLOYEE

2 years ago

yeah looks good, the new install command is working, are builds faster?


Anonymous
TRIALOP

2 years ago

oh yeah, only took like 2 -3 minutes instead of 8 this time


brody
EMPLOYEE

2 years ago

nice


Anonymous
TRIALOP

2 years ago

got alot of more errors i think though lol


brody
EMPLOYEE

2 years ago

missing some packages prob


Anonymous
TRIALOP

2 years 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


Anonymous
TRIALOP

2 years ago

oh wait


Anonymous
TRIALOP

2 years ago

yeah, cuz i pulled


Anonymous
TRIALOP

2 years ago

lemme fix them


brody
EMPLOYEE

2 years ago

add uuid to your packages


brody
EMPLOYEE

2 years ago

also, dotenv can be moved to dev packages


Anonymous
TRIALOP

2 years ago

this right?


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

yes lol


Anonymous
TRIALOP

2 years ago

listen you gotta explain to me like a 4 year old if u havent noticed by now just making sure 😂


Anonymous
TRIALOP

2 years ago

alright, fixing a few here and redeploying


Anonymous
TRIALOP

2 years ago

uncommented my function when syncing sequalize as well to make things cleared, should be a minute


Anonymous
TRIALOP

2 years ago

hmmm, yeah im 99% sure this is a sequalize issue


Anonymous
TRIALOP

2 years ago

omg


Anonymous
TRIALOP

2 years ago

🤦‍♂️


Anonymous
TRIALOP

2 years ago

may have fixed it


Anonymous
TRIALOP

2 years ago

dont ask 👀


Anonymous
TRIALOP

2 years ago

if it keeps crashing imma do more digging myself then get back to u im just waiting now


Anonymous
TRIALOP

2 years ago

<@539512869780455445> fixed it


Anonymous
TRIALOP

2 years ago

only error i get is


Anonymous
TRIALOP

2 years ago

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


brody
EMPLOYEE

2 years ago

we don't need to worry about that, please ignore


brody
EMPLOYEE

2 years ago

so does the backend work? open the domain!


Anonymous
TRIALOP

2 years 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


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

made all my tables and assosioations as well


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

that's awesome, test it with postman? or similar? or do you just wanna deploy your frontend now?


Anonymous
TRIALOP

2 years ago

lemme use postman rq


brody
EMPLOYEE

2 years ago

is your frontend code setup to use that react app backend url variable?


Anonymous
TRIALOP

2 years ago

yep


Anonymous
TRIALOP

2 years ago

for the api urls


brody
EMPLOYEE

2 years ago

for everything?


brody
EMPLOYEE

2 years ago

perfect


brody
EMPLOYEE

2 years ago

see this isn't too hard as long as you have your project structured correctly


Anonymous
TRIALOP

2 years ago

never even knew there was a right or wrong way lol


Anonymous
TRIALOP

2 years ago

also that recent pr you made wasnt mandatory right it was just to make builds faster right?


Anonymous
TRIALOP

2 years ago

gonna seet my data really quick


brody
EMPLOYEE

2 years ago

no not strictly needed, just needed so dependencies aren't cross installed


Anonymous
TRIALOP

2 years ago

still have to study them wepackages and using caddy


brody
EMPLOYEE

2 years ago

you've opened the Caddyfile right?


Anonymous
TRIALOP

2 years ago

yeah but if you ask me i wont remember a thing i kinda glossed over it


Anonymous
TRIALOP

2 years ago

aight rdy to setup frontend


brody
EMPLOYEE

2 years ago

well you can always look back, it's in plain English and fully self documenting


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

and connect my repo or just deploy first?


brody
EMPLOYEE

2 years ago

yeah you can connect your repo too and then deploy all the changes in one go


brody
EMPLOYEE

2 years ago

unless im forgetting something, but i guess we shall find that out


Anonymous
TRIALOP

2 years ago

deploying


Anonymous
TRIALOP

2 years ago

i need to save our convo somehow by the time this is done, taking notes like sanat clause


brody
EMPLOYEE

2 years ago

its not going anywhere



Anonymous
TRIALOP

2 years ago

also i just realized but when i update the repo both of them will redeploy


brody
EMPLOYEE

2 years ago

yeah you can use watchpaths for that


Anonymous
TRIALOP

2 years ago

like in their respective nixpacks? quickly glossing over it while i fix deploy issues



brody
EMPLOYEE

2 years ago

in the service settings


Anonymous
TRIALOP

2 years ago

ah


Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

no clue tbh, ive never used that feature, you will have to play around


Anonymous
TRIALOP

2 years ago

yeah ill give it a go afterwards


Anonymous
TRIALOP

2 years ago

alright


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

something we missed in settings maybe?


brody
EMPLOYEE

2 years ago

why do you say that?


Anonymous
TRIALOP

2 years ago

guessing tbh


Anonymous
TRIALOP

2 years ago

saying things arent disabled


Anonymous
TRIALOP

2 years ago

are disabled *


brody
EMPLOYEE

2 years ago

we dont want caddy to do https, railway handles that


brody
EMPLOYEE

2 years ago

admin endopoint is also useless


Anonymous
TRIALOP

2 years ago

ah so these arent a concern


Anonymous
TRIALOP

2 years ago

domain is working


Anonymous
TRIALOP

2 years ago

soab


Anonymous
TRIALOP

2 years ago

its back


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

the manifest, lemme check it


brody
EMPLOYEE

2 years ago

send link?


Anonymous
TRIALOP

2 years ago

also i have to change some settings in my google cloud console since its in production now one sec



Anonymous
TRIALOP

2 years ago

alright


brody
EMPLOYEE

2 years ago

i got the manifest error, but then i did a hard refresh and the error went away


Anonymous
TRIALOP

2 years ago

yeah same, idk what thats about


brody
EMPLOYEE

2 years ago


brody
EMPLOYEE

2 years ago

blame cache


Anonymous
TRIALOP

2 years ago

doesnt seem to break anything


Anonymous
TRIALOP

2 years ago

deploy is fine but still having some issues that imma see if I can refix rq


Anonymous
TRIALOP

2 years ago

resetting client secrets and a bunch of other stuff so this will take a while


Anonymous
TRIALOP

2 years 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.


Anonymous
TRIALOP

2 years ago

when i check the database sessions are being made


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

from this code


Anonymous
TRIALOP

2 years ago

// 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
      },
    }
  )
);

Anonymous
TRIALOP

2 years ago

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


Anonymous
TRIALOP

2 years ago

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


Anonymous
TRIALOP

2 years ago

as far as deploying goes though liek i said im pretty sure its done successfuly so I can make another post for this if need be


Anonymous
TRIALOP

2 years ago

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 🤔


Anonymous
TRIALOP

2 years ago

switched to a dev environment where i commented these out for local host and it works


Anonymous
TRIALOP

2 years ago

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
      // },
    }
  )
);

Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years 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



brody
EMPLOYEE

2 years 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


brody
EMPLOYEE

2 years ago

in this case, specifically the X-Forwarded-Proto that railway sets to https


Anonymous
TRIALOP

2 years ago

so its railways proxy thats blocking the cookies not my code?


brody
EMPLOYEE

2 years ago

no no it's not blocking anything, I'm not sure how you came to that conclusion


Anonymous
TRIALOP

2 years 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? 🤔


Anonymous
TRIALOP

2 years ago

so I have to set X-Forwarded-Protocol: https in the headers? 🤔


brody
EMPLOYEE

2 years ago

no, and no



Anonymous
TRIALOP

2 years ago

this is where my lack of proxy knowledge is showing


brody
EMPLOYEE

2 years ago

no proxy knowledge needed, railway sets that header for you, you just need to trust it's value


brody
EMPLOYEE

2 years ago

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.


Anonymous
TRIALOP

2 years ago

aaah ok, that makes a bit more sense now. I just assumed it would be https autamtically because its a hosted domain


brody
EMPLOYEE

2 years ago

it is https externally, but express doesn't know that unless it trusts the header


brody
EMPLOYEE

2 years ago

express has a really nice guide


brody
EMPLOYEE

2 years ago

app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);

Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

not quite


Anonymous
TRIALOP

2 years ago

is the proxy service specific?


brody
EMPLOYEE

2 years ago

wdym?


Anonymous
TRIALOP

2 years ago

like would it be from the frontend service or backend service? or is there a universal proxy for railway that everyone uses?


brody
EMPLOYEE

2 years ago

every service that's accessed externally will use a proxy


brody
EMPLOYEE

2 years ago

your frontend already handles this, look into the Caddyfile and there's a line about trusting the proxy


brody
EMPLOYEE

2 years ago

though that is strictly only so you get the correct client IP in the logs, nothing more


Anonymous
TRIALOP

2 years ago

doing some reading rq


brody
EMPLOYEE

2 years ago

just look at the link I sent


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

from the actual request the client made, yes


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

maybe this will give you a good visual?
this endpoint echoes back all the http headers that the app sees during a request


brody
EMPLOYEE

2 years ago

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


Anonymous
TRIALOP

2 years ago

probably 😂 , mind is trying to make sense of what looks like gibberish rn.


Anonymous
TRIALOP

2 years ago

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


Anonymous
TRIALOP

2 years ago

lemme set that up


brody
EMPLOYEE

2 years ago

it trusts the headers the proxy sets, but it only trusts the headers if they where set by a local IP address


Anonymous
TRIALOP

2 years 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 🤞


Anonymous
TRIALOP

2 years ago

I think thats the money emoji lol


brody
EMPLOYEE

2 years ago

close enough


Anonymous
TRIALOP

2 years 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?


Anonymous
TRIALOP

2 years ago

asking because i would have never gotten this on my own and idk if its common knowledge


brody
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years 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


Anonymous
TRIALOP

2 years ago

ok that makes everything 100% more clearer thanks 👍


brody
EMPLOYEE

2 years ago

express is just being picky



brody
EMPLOYEE

2 years ago

picky, but makes sense


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

you dont understand when i say….ive spent weeks just trying to see this 😂


brody
EMPLOYEE

2 years ago

deployment is easy once you have your code in order and understand how the platform works


Anonymous
TRIALOP

2 years 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 ❤️


Anonymous
TRIALOP

2 years ago

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
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years ago

yeah thats why i always assumed 😂 but after doing all this it makes sense because its made to be flexible


brody
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years 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


brody
EMPLOYEE

2 years ago

that's around 600mb of ram, and what's your frontend using? sub 20mb?


Anonymous
TRIALOP

2 years 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
EMPLOYEE

2 years ago

more so about a rule of thumb, don't run development servers


brody
EMPLOYEE

2 years ago

but the alternatives are a case by case basis, and I only have experience with caddy


Anonymous
TRIALOP

2 years ago

ah, makes sense.


brody
EMPLOYEE

2 years ago

caddy for website hosting is definitely the most user friendly, so it works quite well


Anonymous
TRIALOP

2 years ago

I guess you can fiddle with some stuff to and track your usage


brody
EMPLOYEE

2 years ago

have you checked out the metrics service tabs?


Anonymous
TRIALOP

2 years ago

nope lol I havent had a need to because ive had nothing in my project other than the database usually, am now tho


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

outbound?


brody
EMPLOYEE

2 years ago

yeah what about it?


Anonymous
TRIALOP

2 years ago

shouldnt the network be inbound because the backends on railway? or am i reading that wrong <:thonk:969365165688635464>


Anonymous
TRIALOP

2 years ago

stuff like that i guess imma have to learn to


brody
EMPLOYEE

2 years ago

network traffic goes both ways, in and out


Anonymous
TRIALOP

2 years ago

gotcha


Anonymous
TRIALOP

2 years ago

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
EMPLOYEE

2 years ago

I like chicken


Loading...