fix: 修复 H5 静态资源 404,将构建产物放到 /h5/ 路径下
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 56s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-31 21:33:14 +08:00
parent 7062fe19d2
commit 8278136ad1
2 changed files with 6 additions and 2 deletions

View File

@@ -47,7 +47,7 @@ RUN rm -rf /etc/nginx/conf.d/default.conf
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
# 从构建阶段复制构建产物UniApp H5 输出目录) # 从构建阶段复制构建产物UniApp H5 输出目录)
COPY --from=builder /build/dist/build/h5 /usr/share/nginx/html COPY --from=builder /build/dist/build/h5 /usr/share/nginx/html/h5
# 暴露端口 # 暴露端口
EXPOSE 80 EXPOSE 80

View File

@@ -17,10 +17,14 @@ server {
add_header Content-Type text/plain; add_header Content-Type text/plain;
} }
location / { location /h5/ {
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html;
} }
location = / {
return 301 /h5/;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y; expires 1y;
add_header Cache-Control "public, immutable"; add_header Cache-Control "public, immutable";