修复预览控制台子路径静态资源
Project CI / Repository checks (push) Successful in 1m3s
Project CI / Frontend tests (push) Successful in 3m1s
Project CI / Backend tests (push) Successful in 3m46s
Project CI / Native shell tests (push) Failing after 12m48s

让控制服务原生托管 /build 页面与静态资源
保持内网 Nginx 路径透传并补充部署合同检查
This commit is contained in:
2026-08-15 17:25:40 +08:00
parent 41874ab391
commit 1746c77cb1
3 changed files with 20 additions and 6 deletions
@@ -3,7 +3,7 @@ location = /build {
}
location ^~ /build/ {
proxy_pass http://127.0.0.1:8410/;
proxy_pass http://127.0.0.1:8410;
proxy_http_version 1.1;
proxy_set_header Host $host;
+9
View File
@@ -21,6 +21,10 @@ const systemd = readFileSync(
'deploy/systemd/genarrative-preview-deployer.service',
'utf8',
);
const server = readFileSync(
'server-rs/crates/preview-deployer-server/src/lib.rs',
'utf8',
);
const nginx = readFileSync(
'deploy/nginx/genarrative-preview-deployer-lan.conf',
'utf8',
@@ -118,6 +122,11 @@ assertIncludes(
'location ^~ /build/',
'内网 Nginx 必须提供 /build/ 路由。',
);
assertIncludes(
server,
'.nest_service("/build/assets", ServeDir::new(static_dir.join("assets")))',
'控制服务必须原生托管 /build 子路径,不能依赖 Nginx 隐式改写。',
);
assertIncludes(
jobConfig,
'<scriptPath>jenkins/Jenkinsfile.preview-deployer</scriptPath>',
@@ -234,11 +234,16 @@ pub fn build_router(state: AppState) -> Router {
let mut router = Router::new().merge(api);
if let Some(static_dir) = state.config.static_dir.clone() {
router = router.fallback_service(
ServeDir::new(&static_dir)
.append_index_html_on_directories(true)
.fallback(ServeFile::new(static_dir.join("index.html"))),
);
let index = static_dir.join("index.html");
router = router
.route_service("/build", ServeFile::new(index.clone()))
.route_service("/build/", ServeFile::new(index.clone()))
.nest_service("/build/assets", ServeDir::new(static_dir.join("assets")))
.fallback_service(
ServeDir::new(&static_dir)
.append_index_html_on_directories(true)
.fallback(ServeFile::new(index)),
);
}
router