fix(6): resolve static asset serving and proxy header issues

Fixed issues:
1. Caddy not forwarding X-Forwarded headers to Next.js
   - Added X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host
2. Removed X-Content-Type-Options: nosniff (blocks static assets)
3. Copy static files to standalone build directory
   - Next.js standalone requires files in .next/standalone/.next/static/
4. Made script auto-copy static files after build

Result:
  ✓ CSS/JS loading with correct MIME types (text/css, text/javascript)
  ✓ Frontend fully rendering via HTTPS
  ✓ All static assets cached and served correctly
  ✓ Tested working via IP address (192.168.84.131:8919)
This commit is contained in:
2026-04-22 19:34:32 +03:00
parent 0deef7f601
commit 0881b0ecee
2 changed files with 20 additions and 3 deletions

View File

@@ -177,6 +177,14 @@ class StandaloneServerManager:
if result.returncode != 0:
self.error(f"Frontend build failed with exit code {result.returncode}")
# Copy static files to standalone directory (required for Next.js standalone mode)
static_src = frontend_dir / ".next" / "static"
static_dst = frontend_dir / ".next" / "standalone" / ".next" / "static"
if static_src.exists() and not static_dst.exists():
self.log("Copying static files to standalone build...")
import shutil
shutil.copytree(static_src, static_dst)
def start_backend(self):
"""Start FastAPI backend server"""
self.log(f"Starting backend on port {self.backend_port}...")