From 35250fa3081ab02e75369bc81c025587d0af5e5b Mon Sep 17 00:00:00 2001 From: Ephraim Duncan <55143799+ephraimduncan@users.noreply.github.com> Date: Mon, 27 Oct 2025 06:24:24 +0000 Subject: [PATCH] feat: server port configurable via PORT env (#2097) --- .env.example | 4 ++++ apps/openpage-api/package.json | 2 +- apps/remix/server/main.js | 4 +++- apps/remix/vite.config.ts | 2 +- packages/tsconfig/process-env.d.ts | 1 + turbo.json | 1 + 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 6190dfb03..980792eb6 100644 --- a/.env.example +++ b/.env.example @@ -29,6 +29,10 @@ NEXT_PUBLIC_WEBAPP_URL="http://localhost:3000" # URL used by the web app to request itself (e.g. local background jobs) NEXT_PRIVATE_INTERNAL_WEBAPP_URL="http://localhost:3000" +# [[SERVER]] +# OPTIONAL: The port the server will listen on. Defaults to 3000. +PORT=3000 + # [[DATABASE]] NEXT_PRIVATE_DATABASE_URL="postgres://documenso:password@127.0.0.1:54320/documenso" # Defines the URL to use for the database when running migrations and other commands that won't work with a connection pool. diff --git a/apps/openpage-api/package.json b/apps/openpage-api/package.json index 8e5447cca..3cb30a01d 100644 --- a/apps/openpage-api/package.json +++ b/apps/openpage-api/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "next dev -p 3003", "build": "next build", - "start": "next start", + "start": "next start -p 3003", "lint:fix": "next lint --fix", "clean": "rimraf .next && rimraf node_modules" }, diff --git a/apps/remix/server/main.js b/apps/remix/server/main.js index b6046e469..e0d54f65c 100644 --- a/apps/remix/server/main.js +++ b/apps/remix/server/main.js @@ -30,4 +30,6 @@ server.use( const handler = handle(build, server); -serve({ fetch: handler.fetch, port: 3000 }); +const port = parseInt(process.env.PORT || '3000', 10); + +serve({ fetch: handler.fetch, port }); diff --git a/apps/remix/vite.config.ts b/apps/remix/vite.config.ts index 0e0005515..3f3723197 100644 --- a/apps/remix/vite.config.ts +++ b/apps/remix/vite.config.ts @@ -21,7 +21,7 @@ export default defineConfig({ }, }, server: { - port: 3000, + port: parseInt(process.env.PORT || '3000', 10), strictPort: true, }, plugins: [ diff --git a/packages/tsconfig/process-env.d.ts b/packages/tsconfig/process-env.d.ts index 7962031f5..d4c23cd18 100644 --- a/packages/tsconfig/process-env.d.ts +++ b/packages/tsconfig/process-env.d.ts @@ -1,5 +1,6 @@ declare namespace NodeJS { export interface ProcessEnv { + PORT?: string; NEXT_PUBLIC_WEBAPP_URL?: string; NEXT_PRIVATE_GOOGLE_CLIENT_ID?: string; diff --git a/turbo.json b/turbo.json index d767b4612..d2217d211 100644 --- a/turbo.json +++ b/turbo.json @@ -38,6 +38,7 @@ "globalDependencies": ["**/.env.*local"], "globalEnv": [ "APP_VERSION", + "PORT", "NEXT_PRIVATE_ENCRYPTION_KEY", "NEXT_PRIVATE_ENCRYPTION_SECONDARY_KEY", "NEXTAUTH_SECRET",