Skip to content

Conversation

@MOHIT-SOLANKII
Copy link

@MOHIT-SOLANKII MOHIT-SOLANKII commented Jan 19, 2026

What does this PR do?

This PR fixes issue #2684, where the "Download assets" button on the /assets page returns a 404 Not Found error in the production environment.

Problem :

The custom Node.js production server (server/main.js) was configured to handle Server-Side Rendering (SSR) via h3 and the SvelteKit node adapter, but it lacked the middleware to serve static files (like assets.zip, images, etc.) that originate from the static/ directory and are copied to build/client during build.

Solution :

  • Added sirv : Introduced sirv as a production dependency to efficiently serve static files.
  • Updated server/main.js : Added middleware to serve files from the build/client directory before the main SvelteKit handler. This ensures that if a static file exists, it is served; otherwise, the request falls through to the app router.

Test Plan

Verified the fix by running the production server locally (node server/main.js) and confirming that static files (like assets.zip) are correctly served from the build output directory (build/client/) with the correct 200 OK headers.

Related PRs and Issues

Fixes #2684

Have you read the Contributing Guidelines on issues?

Yes

Summary by CodeRabbit

  • Chores
    • Improved static asset delivery for the app: files are now served with compression and stronger caching (gzip, ETag, immutable, max-age), reducing load times and bandwidth.
    • Static assets are served earlier in the request flow to improve responsiveness and caching efficiency for end users.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Walkthrough

A new dependency "sirv" (^3.0.2) is added to package.json. In server/main.js, sirv is imported and configured via fromNodeMiddleware to serve static files from build/client at the root path. The middleware is enabled with gzip, etag, maxAge, and immutable options and is mounted before the existing request handler. No exported/public API changes were made.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding sirv middleware to serve static assets in production, which directly addresses the core issue.
Linked Issues check ✅ Passed The PR successfully implements the coding requirements from issue #2684 by adding sirv dependency and configuring static file serving middleware to resolve the 404 error on asset downloads.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objective: adding sirv dependency and mounting static middleware. No unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Branding page: “Download assets” button not working

1 participant