[PR #6590] fix(web): add Content-Type headers for proxied static assets #11988

Closed
opened 2026-02-16 18:16:55 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6590

State: closed
Merged: No


Summary

Fixes #6557

The opencode web command proxies static assets from app.opencode.ai, but Cloudflare doesn't return Content-Type headers for these files. Browsers reject ES modules without proper MIME types, causing the web UI to fail loading with the error:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of ""

Changes

  • Added Content-Type detection based on file extension in the proxy handler
  • Supports .js, .css, .html, .json, .svg, .png, .ico, .woff, .woff2
  • Only sets Content-Type when the proxied response doesn't include one

Testing

Tested locally with opencode web --port 3006:

  • JavaScript modules load correctly with Content-Type: application/javascript
  • CSS loads with Content-Type: text/css
  • Web UI renders without console errors
  • No regression for other endpoints
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6590 **State:** closed **Merged:** No --- ## Summary Fixes #6557 The `opencode web` command proxies static assets from app.opencode.ai, but Cloudflare doesn't return Content-Type headers for these files. Browsers reject ES modules without proper MIME types, causing the web UI to fail loading with the error: ``` Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "" ``` ## Changes - Added Content-Type detection based on file extension in the proxy handler - Supports `.js`, `.css`, `.html`, `.json`, `.svg`, `.png`, `.ico`, `.woff`, `.woff2` - Only sets Content-Type when the proxied response doesn't include one ## Testing Tested locally with `opencode web --port 3006`: - ✅ JavaScript modules load correctly with `Content-Type: application/javascript` - ✅ CSS loads with `Content-Type: text/css` - ✅ Web UI renders without console errors - ✅ No regression for other endpoints
yindo added the pull-request label 2026-02-16 18:16:55 -05:00
yindo closed this issue 2026-02-16 18:16:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11988