diff --git a/docker-compose.yml b/docker-compose.yml index 6adf136..6f82cfa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: JWT_SECRET: replace-me-with-a-random-string ALLOW_REGISTER: "false" ALLOW_OPENAPI: "true" + SERVER_URL: depends_on: - postgres restart: always diff --git a/src/server/router/serverStatus.ts b/src/server/router/serverStatus.ts index 884c363..918175c 100644 --- a/src/server/router/serverStatus.ts +++ b/src/server/router/serverStatus.ts @@ -3,6 +3,7 @@ import { body, header, param, validate } from '../middleware/validate'; import { recordServerStatus } from '../model/serverStatus'; import fs from 'fs-extra'; import path from 'path'; +import { env } from '../utils/env'; export const serverStatusRouter = Router(); @@ -34,7 +35,7 @@ serverStatusRouter.get( validate(param('workspaceId').isString()), async (req, res) => { const { workspaceId } = req.params; - const server = `${req.protocol}://${req.get('Host')}`; + const server = env.serverUrl || `${req.protocol}://${req.get('Host')}`; res .setHeader('Content-Type', 'text/plain') diff --git a/src/server/utils/env.ts b/src/server/utils/env.ts index cf6f826..ccc6e50 100644 --- a/src/server/utils/env.ts +++ b/src/server/utils/env.ts @@ -2,6 +2,7 @@ export const env = { allowRegister: checkEnvTrusty(process.env.ALLOW_REGISTER), allowOpenapi: checkEnvTrusty(process.env.ALLOW_OPENAPI), websiteId: process.env.WEBSITE_ID, + serverUrl: process.env.SERVER_URL, // example: https://tianji.example.com }; export function checkEnvTrusty(env: string | undefined): boolean {