From 167a284da90057de50b8b480100fb1907f9baa72 Mon Sep 17 00:00:00 2001 From: Vaica <94612053+zqlit@users.noreply.github.com> Date: Mon, 22 Jun 2026 12:40:40 +0800 Subject: [PATCH] 1240 --- write-server/nginx/conf.d/write-server.conf | 11 ++++++++++- write-server/src/lib/hugo.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/write-server/nginx/conf.d/write-server.conf b/write-server/nginx/conf.d/write-server.conf index cbf11646..6344f2c3 100644 --- a/write-server/nginx/conf.d/write-server.conf +++ b/write-server/nginx/conf.d/write-server.conf @@ -49,9 +49,18 @@ server { } # Hugo 预览代理(不需要认证) + # Hugo 静态资源 + location ~ ^/(css|js|font|fonts|image/background|image/avatar|image/reward|emotion)/ { + auth_request off; + proxy_pass http://write-server:1313; + proxy_set_header Host $host; + } + + # Hugo 页面预览 location /preview/ { auth_request off; - proxy_pass http://write-server:1313/preview/; + rewrite ^/preview/(.*)$ /$1 break; + proxy_pass http://write-server:1313; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } diff --git a/write-server/src/lib/hugo.ts b/write-server/src/lib/hugo.ts index 7a056ad3..dbf1a3d9 100644 --- a/write-server/src/lib/hugo.ts +++ b/write-server/src/lib/hugo.ts @@ -18,7 +18,7 @@ class HugoManager { this.starting = true; this.ready = false; - this.process = spawn("hugo", ["server", "--bind", "0.0.0.0", "--port", "1313", "--baseURL", "/preview/", "--disableFastRender", "--noHTTPCache"], { + this.process = spawn("hugo", ["server", "--bind", "0.0.0.0", "--port", "1313", "--disableFastRender", "--noHTTPCache"], { cwd: BLOG_ROOT, shell: true, stdio: "pipe",