refactor: add server url for serverStatus
This commit is contained in:
parent
7d7519203c
commit
09ec432f16
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user