mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复 QlBaseUrl 末尾不加斜杠无法访问
This commit is contained in:
parent
d3023d31e3
commit
2a41f64d1b
|
@ -63,7 +63,7 @@ docker run -dit \
|
|||
-v $PWD/ql/data:/ql/data \
|
||||
# The 5700 after the colon is the default port, if QlPort is set, it needs to be the same as QlPort.
|
||||
-p 5700:5700 \
|
||||
# Deployment paths are not required and begin and end with a slash, e.g. /test/.
|
||||
# Deployment paths are not required, e.g. /test.
|
||||
-e QlBaseUrl="/" \
|
||||
# Deployment port is not required, when using host mode, you can set the port after service startup, default 5700
|
||||
-e QlPort="5700" \
|
||||
|
@ -95,7 +95,7 @@ podman run -dit \
|
|||
-v $PWD/ql/data:/ql/data \
|
||||
# The 5700 after the colon is the default port, if QlPort is set, it needs to be the same as QlPort.
|
||||
-p 5700:5700 \
|
||||
# Deployment paths are not required and begin and end with a slash, e.g. /test/.
|
||||
# Deployment paths are not required, e.g. /test.
|
||||
-e QlBaseUrl="/" \
|
||||
# Deployment port is not required, when using host mode, you can set the port after service startup, default 5700
|
||||
-e QlPort="5700" \
|
||||
|
|
|
@ -65,7 +65,7 @@ docker run -dit \
|
|||
-v $PWD/ql/data:/ql/data \
|
||||
# 冒号后面的 5700 为默认端口,如果设置了 QlPort, 需要跟 QlPort 保持一致
|
||||
-p 5700:5700 \
|
||||
# 部署路径非必须,以斜杠开头和结尾,比如 /test/
|
||||
# 部署路径非必须,比如 /test
|
||||
-e QlBaseUrl="/" \
|
||||
# 部署端口非必须,当使用 host 模式时,可以设置服务启动后的端口,默认 5700
|
||||
-e QlPort="5700" \
|
||||
|
@ -97,7 +97,7 @@ podman run -dit \
|
|||
-v $PWD/ql/data:/ql/data \
|
||||
# 冒号后面的 5700 为默认端口,如果设置了 QlPort, 需要跟 QlPort 保持一致
|
||||
-p 5700:5700 \
|
||||
# 部署路径非必须,以斜杠开头和结尾,比如 /test/
|
||||
# 部署路径非必须,比如 /test
|
||||
-e QlBaseUrl="/" \
|
||||
# 部署端口非必须,当使用 host 模式时,可以设置服务启动后的端口,默认 5700
|
||||
-e QlPort="5700" \
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'reflect-metadata'; // We need this in order to use @Decorators
|
|||
import config from './config';
|
||||
import express from 'express';
|
||||
import Logger from './loaders/logger';
|
||||
import path from 'path';
|
||||
|
||||
async function startServer() {
|
||||
const app = express();
|
||||
|
|
|
@ -6,6 +6,14 @@ let pickedEnv: Record<string, string>;
|
|||
function getPickedEnv() {
|
||||
if (pickedEnv) return pickedEnv;
|
||||
const picked = pick(process.env, ['QlBaseUrl', 'DeployEnv']);
|
||||
if (picked.QlBaseUrl) {
|
||||
if (!picked.QlBaseUrl.startsWith('/')) {
|
||||
picked.QlBaseUrl = `/${picked.QlBaseUrl}`
|
||||
}
|
||||
if (!picked.QlBaseUrl.endsWith('/')) {
|
||||
picked.QlBaseUrl = `${picked.QlBaseUrl}/`
|
||||
}
|
||||
}
|
||||
pickedEnv = picked as Record<string, string>;
|
||||
return picked;
|
||||
}
|
||||
|
|
|
@ -407,8 +407,18 @@ init_nginx() {
|
|||
local aliasStr=""
|
||||
local rootStr=""
|
||||
if [[ $ql_base_url != "/" ]]; then
|
||||
if [[ $ql_base_url != /* ]]; then
|
||||
ql_base_url="/$ql_base_url"
|
||||
fi
|
||||
if [[ $ql_base_url != */ ]]; then
|
||||
ql_base_url="$ql_base_url/"
|
||||
fi
|
||||
location_url="^~${ql_base_url%*/}"
|
||||
aliasStr="alias ${dir_static}/dist;"
|
||||
if ! grep -q "<base href=\"$ql_base_url\">" "${dir_static}/dist/index.html"; then
|
||||
awk -v text="<base href=\"$ql_base_url\">" '/<link/ && !inserted {print text; inserted=1} 1' "${dir_static}/dist/index.html" > temp.html
|
||||
mv temp.html "${dir_static}/dist/index.html"
|
||||
fi
|
||||
else
|
||||
rootStr="root ${dir_static}/dist;"
|
||||
fi
|
||||
|
|
|
@ -178,7 +178,7 @@ export default function () {
|
|||
useEffect(() => {
|
||||
if (!user || !user.username) return;
|
||||
const ws = WebSocketManager.getInstance(
|
||||
`${window.location.origin}/api/ws?token=${localStorage.getItem(
|
||||
`${window.location.origin}${window.__ENV__QlBaseUrl || '/'}api/ws?token=${localStorage.getItem(
|
||||
config.authKey,
|
||||
)}`,
|
||||
);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ES2015",
|
||||
"moduleResolution": "Bundler",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"jsx": "react-jsx",
|
||||
"esModuleInterop": true,
|
||||
|
@ -25,14 +25,7 @@
|
|||
"include": ["src/**/*", ".umirc.ts", "typings.d.ts", "back/**/*"],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib",
|
||||
"es",
|
||||
"static",
|
||||
"data",
|
||||
"typings",
|
||||
"**/__test__",
|
||||
"test",
|
||||
"docs",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user