Angular SSR

I'm planning to deploy an angular app with server side rendering. Does Railway support it?
At the moment the rendering is in the browser. I have build and start scripts in my package json that looks like this
"build": "ng build --configuration $NODE_ENV",
"start": "serve dist/app-name -s -n -L -p $PORT",
but with server side rendering it's a bit different
"serve:ssr": "node dist/app-name/server/main.js",
According to Angular docs: Starts the server script for serving the application locally with server-side rendering. It uses the build artifacts created by npm run build:ssr, so make sure you have run that command as well. serve:ssr is not intended to be used to serve your application in production, but only for testing the server-side rendered application locally.
"build:ssr": "ng build && ng run app-name:server",
According to Angular docs: Builds both the server script and the application in production mode. Use this command when you want to build the project for deployment.
i have different environments on Railway and I want to build for them, so I can modify "build:ssr": "ng build && ng run app-name:server" to "build:ssr": "ng build --configuration $NODE_ENV && ng run app-name:server". And perhaps I can substitute
"build": "ng build --configuration $NODE_ENV" with "build": "ng build --configuration $NODE_ENV && ng run app-name:server".
But I'm a little bit doubtful about how I should modify the start script. Could this work:
"start": "node dist/app-name/server/main.js -s -n -L -p $PORT" ?
Update: I have tested the above setup and successfully deployed to my test environment
the -s -n -L -p flags are specific to the serve package and are not universal
Can I omit them then?
well yes they don't pertain to angulars built server
but angulars built server will still need to listen on and $PORT
It actually does and defaults to 4000
const port = process.env['PORT'] || 4000;
thanks again
no problem

Looking for more? Join the community!

Recommended Posts
Killed Errorhello can somebody help me with this its not starting my projectTerrafoam thingyMy friend told me to learn terrafoarm(this sounds wrong i forgot what its called) Anyway what does iDocker Build Error``` ============== Using Nixpacks ============== context: 009fc5728ee64eb7a597ef6570e251a0 ╔making linux program available in nixpacksHi, I want to run a golang app on railway. Within this app i use the following dependency https://giIs it normal for a deployment to be initializing this long?https://cdn.fl1nt.dev/GAGE1/YAdogAtO61.png I don't think this is normal, none of my deployments takUpdating N8N Service Via Railway CLIHello, I created a Railway project and installed N8N via a Railway template. The version I am on is Ephemeral storage concernHi I want to do programmatic NPM publishes using a Railway service I will need to basically use shelredploy after pushin to github not working anymoreit stopped to redeploy my appProject failing to deploy - 'no space available'Project: 13b3222b-eb44-433c-ad71-9174aa430a7d Has been deploying fine but started to complain about"Waiting" to deploy for 18 hours? Am I doing something wrong?I'm trying to move an app I deployed personally to a new account by setting up a new account and newQ: Help with Deploying a Medusa Server to RailwaySo, it keeps saying server crashed, but in the logs, nothing seems to be an issue. Been at it backHow do i move my project under the pro plan i just moved to?I just migrated from hobby to Pro - how do i move my projects under this? it says i need an active sDeploy appwrite on railway apphow to deploy appwrite in railway app ? , as fullstack i really like appwrite as backend and Next jsCurrent usage is $ 3.13 but current bill $5.00Please let me know how it's works, should I pay $5 for next month Project: af5712a6-cd8f-4b70-93f8-1Cannot create code snapshot right nowCannot create code snapshot right now, please review your last commit or try again If this error perrailway mediasoup portsHello, can I run mediasoup on railway? I have this errors when I try to run it. ``` Error: port binrailway cache not clearing despite NIXPACKS_NO_CACHEas title says. my railway server is not deploying without using cache.Security Page for RailwayDoes Railway have a privacy/security page that we could reference to fulfill requirements from custoBig memory usageI have a nodejs app running some tasks and it seems like the ram is increadibly high in the railway Cannot terminate old instanceI have an old instance running alongside the latest one, and I cannot find a way to terminate it thr