Skip to content

fix: clarify differences in res.jsonp() behavior and security measures#2366

Open
spiderocious wants to merge 1 commit into
expressjs:mainfrom
spiderocious:docs/clarify-res-jsonp-differences
Open

fix: clarify differences in res.jsonp() behavior and security measures#2366
spiderocious wants to merge 1 commit into
expressjs:mainfrom
spiderocious:docs/clarify-res-jsonp-differences

Conversation

@spiderocious
Copy link
Copy Markdown

@spiderocious spiderocious commented Jun 2, 2026

Problem

The res.jsonp API reference says the method is "identical to res.json(), except that it opts-in to JSONP callback support". As discussed in #1330, that's understating things: when the callback query parameter is present, res.jsonp also forces the Content-Type to text/javascript (and per @dougwilson's confirmation, this can't be overridden because no other content type will execute as JSONP in a browser), adds X-Content-Type-Options: nosniff, and prefixes the body with /**/ as a security mitigation against the Rosetta Flash JSONP attack.

Fix

Replace the misleading "identical" line with a short bulleted description of the actual differences, in both the 4x and 5x API references. The existing examples and "jsonp callback name" override section are unchanged.

closes #1330

@spiderocious spiderocious requested a review from a team as a code owner June 2, 2026 13:33
@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 2, 2026

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 27c2e97
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/6a1edb974b9b3b00083624a2
😎 Deploy Preview https://deploy-preview-2366--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

Possible gap in documentation re res.json and res.jsonp

1 participant