fix(assets): set js content-type on dev bundled asset handler#748
Conversation
Dev handler returned a Buffer without a Content-Type header, causing
Firefox to reject bundled scripts with "MIME type ('') is not a valid
JavaScript MIME type".
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe change adds an import for Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/script/src/assets.ts (2)
61-61: 💤 Low valueConsider
text/javascript— the current IANA-registered standard MIME type.
application/javascriptnow carries the IANA note "OBSOLETED in favor oftext/javascript" per RFC 9239 (May 2022). That said, browsers still have to accept all JavaScript MIME types, so this won't break anything — but servers should sendtext/javascriptfor forward compliance.♻️ Proposed change
- setHeader(event, 'content-type', 'application/javascript; charset=utf-8') + setHeader(event, 'content-type', 'text/javascript; charset=utf-8')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/script/src/assets.ts` at line 61, The response sets the JavaScript MIME type to application/javascript; update the header in the setHeader call to use the IANA-preferred text/javascript with charset by changing the value passed to setHeader(event, 'content-type', ...) from 'application/javascript; charset=utf-8' to 'text/javascript; charset=utf-8' so the setHeader invocation uses the forward-compatible MIME type.
61-61: 💤 Low valueConsider using
text/javascript— the current IANA standard for JavaScript MIME types.Per RFC 9239 (May 2022) and IANA's official registration,
text/javascriptis the sole standard media type for JavaScript resources, andapplication/javascriptis listed as a deprecated alias. Both work identically in all browsers, so this is purely an optional standards alignment. The single-line change ensures the code uses the current standard rather than an obsolete name.♻️ Proposed change
- setHeader(event, 'content-type', 'application/javascript; charset=utf-8') + setHeader(event, 'content-type', 'text/javascript; charset=utf-8')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/script/src/assets.ts` at line 61, Replace the deprecated MIME type used in the setHeader call: in the setHeader(event, 'content-type', 'application/javascript; charset=utf-8') invocation update the media type to the current IANA standard by using 'text/javascript; charset=utf-8' so the Content-Type header aligns with RFC 9239.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/script/src/assets.ts`:
- Line 61: The response sets the JavaScript MIME type to application/javascript;
update the header in the setHeader call to use the IANA-preferred
text/javascript with charset by changing the value passed to setHeader(event,
'content-type', ...) from 'application/javascript; charset=utf-8' to
'text/javascript; charset=utf-8' so the setHeader invocation uses the
forward-compatible MIME type.
- Line 61: Replace the deprecated MIME type used in the setHeader call: in the
setHeader(event, 'content-type', 'application/javascript; charset=utf-8')
invocation update the media type to the current IANA standard by using
'text/javascript; charset=utf-8' so the Content-Type header aligns with RFC
9239.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bd212bb1-dd33-40e3-a7ad-66c1224da4e9
📒 Files selected for processing (1)
packages/script/src/assets.ts
commit: |
Summary
packages/script/src/assets.tsreturned aBufferwithout aContent-Typeheader, so Firefox rejected bundled scripts (/_scripts/assets/<hash>.js) withMIME type ("") is not a valid JavaScript MIME type.application/javascript; charset=utf-8explicitly before returning content.Closes part of #746 (the dev-side MIME warning). The production
/_nuxt/*.jsbeing served asapplication/jsonreported in that issue is unrelated, that's a reverse-proxy/CDN misconfiguration on the user's side.Test plan
bundle: truein dev, confirm/_scripts/assets/*.jsnow responds withcontent-type: application/javascript; charset=utf-8.