R
Railway2y ago
guypy

Deploying NextJS app on an NX Monorepo

Hey! I'm trying to deploy an NX monorepo containing a NodeJS/Express app, and 2 NextJS apps. I've set up the build commands for each app to be nx run <APP_NAME>:build:production, and the start commands to be nx run <APP_NAME>:serve:production. The ports on NX apps are set in a configuration file that doesn't support env variables, so I've set a variable PORT for each of the applications on Railway. Deploying the NodeJS app is working fine, however, the NextJS apps seem to be started just fine on the expected port (I see a [ ready ] on http://localhost:4200 log message), but when I try to go to the app's URL I get the "Is your app correctly listening on $PORT?" error. Any ideas how to make this work? Thanks!
4 Replies
Percy
Percy2y ago
Project ID: 4c244bec-c9dc-4d97-b44d-c09dcf0b97d3
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Adam
Adam2y ago
@tomray.dev set a PORT environment variable to the port that your app is listening on. Even if your app is not listening on that environment variable, Railway will be
guypy
guypyOP2y ago
@tomray.dev I used the PORT env var, as well as NIXPACKS_NX_APP_NAME. The combination of them seemed to do the trick ✌️
Want results from more Discord servers?
Add your server