perf: remove env SERVER_URL and use url to get real server url

This commit is contained in:
moonrailgun 2024-01-04 00:19:23 +08:00
parent 28dd506cb4
commit 81e7f8651a
5 changed files with 4 additions and 6 deletions

View File

@ -9,7 +9,6 @@ services:
JWT_SECRET: replace-me-with-a-random-string
ALLOW_REGISTER: "false"
ALLOW_OPENAPI: "true"
SERVER_URL:
depends_on:
- postgres
restart: always

View File

@ -294,7 +294,7 @@ ServerList.displayName = 'ServerList';
export const InstallScript: React.FC = React.memo(() => {
const workspaceId = useCurrentWorkspaceId();
const command = `curl -o- ${window.location.origin}/serverStatus/${workspaceId}/install.sh | bash`;
const command = `curl -o- ${window.location.origin}/serverStatus/${workspaceId}/install.sh?url=${window.location.origin} | bash`;
return (
<div>

View File

@ -35,7 +35,9 @@ serverStatusRouter.get(
validate(param('workspaceId').isString()),
async (req, res) => {
const { workspaceId } = req.params;
const server = env.serverUrl || `${req.protocol}://${req.get('Host')}`;
const queryUrl = req.query.url ? String(req.query.url) : undefined;
const server = queryUrl || `${req.protocol}://${req.get('Host')}`;
res
.setHeader('Content-Type', 'text/plain')

View File

@ -2,7 +2,6 @@ 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
sandboxMemoryLimit: process.env.SANDBOX_MEMORY_LIMIT
? Number(process.env.SANDBOX_MEMORY_LIMIT)
: 16, // MB

View File

@ -24,8 +24,6 @@ vim docker-compose.yml
you should change `JWT_SECRET` to make your token safe.
and change `SERVER_URL` to make sure you can quick run `install.sh` in server status report if you have many level gateway.
Then, run it!
```