修复预览控制台子路径静态资源
让控制服务原生托管 /build 页面与静态资源 保持内网 Nginx 路径透传并补充部署合同检查
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user