"Missing X-Content-Type-Options header": how to fix it
Last reviewed November 23, 2026 against the providers' current documentation.
The short version
Send X-Content-Type-Options: nosniff as an HTTP response header on every response from your site, using your host's header config (a _headers file, vercel.json, nginx, Apache) or helmet() in Express. nosniff is the only value. Then make sure your JavaScript files are served as JavaScript and your CSS as text/css, because with nosniff the browser blocks scripts and stylesheets served with the wrong type.
Why it matters
Browsers used to guess a file's type from its contents ("MIME sniffing") when the server's Content-Type looked wrong. That guess can be abused: MDN warns that browsers "might incorrectly detect non-script and non-stylesheet files as scripts or stylesheets", so a file that was never meant to run can be loaded as one, and MDN's header reference says nosniff "prevents XSS-attacks where user-uploaded content is executed as an HTML document". With nosniff, the browser uses the Content-Type you sent as-is and blocks a script or stylesheet whose type doesn't match. MDN's MIME types guide says "All sites must set the X-Content-Type-Options header with a value of nosniff", and its reference adds that "Site security testers usually expect this header to be set". It's rated low on our free check (GitLab's scanner rates it low too) because it only matters together with another mistake, most often letting users upload files that your site then serves back. It's also one line of config, and it shows up on almost every pen-test report and security questionnaire, so it's worth the two minutes.
Fix it, in this order
See what your site sends now
Run the free headers check on your live address. Missing X-Content-Type-Options header means the page's response had noX-Content-Type-Optionsheader with the valuenosniff. From a terminal:curl -sI https://yourdomain.com | grep -i x-content-type-options. Also check one of your JavaScript files (copy a/assets/….jsaddress from the page source):curl -sI https://yourdomain.com/assets/index-abc123.js | grep -iE 'content-type|x-content-type'.Add the header in your host's config
It has to be an HTTP response header, set where your host sets headers. Add it for every path, not only the home page:
Helmet sends# Netlify, Cloudflare Pages or Workers static assets: _headers in your static folder (Vite: public/) /* X-Content-Type-Options: nosniff # Vercel: vercel.json { "headers": [ { "source": "/(.*)", "headers": [ { "key": "X-Content-Type-Options", "value": "nosniff" } ] } ] } # nginx: server block (always = also on error pages) add_header X-Content-Type-Options "nosniff" always; # Apache (mod_headers) Header always set X-Content-Type-Options "nosniff" # Express (Replit and other Node servers): Helmet sends it by default app.use(helmet())X-Content-Type-Options: nosniffby default, so if your Express app already useshelmet()and the header is still missing, your pages are probably served by something else (a CDN, a static host in front, or a route that runs before Helmet). More per-host detail: Netlify, Vercel. Cloudflare's docs say_headersrules don't apply to responses from Pages Functions or Worker code, so set it in code there.Make sure your files have the right Content-Type
nosniffonly breaks something when a file is served with the wrong type: MDN says the browser "blocks the response if the MIME type doesn't match an expected type" for scripts (a JavaScript type) and stylesheets (text/css). Modern hosts get this right for your built.jsand.cssfiles. The usual trap in single-page apps is a missing file: after a redeploy, an old chunk name falls through to the SPA fallback and comes back asindex.html(text/html), which the browser now refuses to run, with a MIME type error in the console. That's a missing file, not anosniffproblem; fix the path or the cache, don't remove the header.Serve user uploads safely
If your app lets people upload files (avatars, attachments) and serves them from your own domain, store the real type with each file, serve them with thatContent-Typeandnosniff, and send files you don't want shown in the browser as downloads (Content-Disposition: attachment). OWASP's advice is to "Set the Content-Type header correctly throughout the site". Serving uploads from a separate storage domain (Supabase Storage, S3, Cloudflare R2) instead of your app's domain keeps a bad file away from your logged-in pages.Check it worked
Rerun the headers check or the curl commands above on the home page and one JavaScript file, then open the app and its main pages with the browser console open and look for MIME type errors.
Or ask your AI tool to do it
Paste this into Lovable, Bolt, Cursor, Claude Code or whichever tool built your app. Review what it changes before you deploy.
Add the HTTP response header X-Content-Type-Options: nosniff to every response my web app sends (pages, JavaScript, CSS, API responses, files). Use my host's header config, not a meta tag: a _headers file in the static folder that gets copied to the build output (Netlify, Cloudflare Pages, Cloudflare Workers static assets; for Vite that's public/), vercel.json headers on Vercel, add_header ... always in nginx, Header always set in Apache, or helmet() in Express (it sends nosniff by default). Make sure responses from server code or functions get it too. Then check that every JavaScript file is served with a JavaScript Content-Type and every stylesheet with text/css, and that a request for a missing .js or .css file returns a 404 instead of index.html. If the app serves user-uploaded files, serve each one with its stored Content-Type and Content-Disposition: attachment for anything that shouldn't open in the browser. List what you changed.
How this happens
Like the other security headers, X-Content-Type-Options lives in the hosting config, and AI builders like Lovable, Bolt, v0 or Cursor write the app, not the headers file, so unless someone adds one it's missing. When an AI tool does try, it sometimes puts it in a <meta http-equiv> tag in index.html; our check (like other scanners) reads the response headers, so move it to your host's config.
Check that it's really fixed
After you deploy, run the free check. It reads your live site the way an attacker would and tells you if any secret key is still visible.
Topic check: Security headers check
Find the other leaks before someone else does
The free check reads your home page and its scripts. The website security report goes through up to 30 pages and 40 JavaScript files, plus .env and .git files, security headers, cookies and CORS, domain and email records, and libraries with known vulnerabilities. Every finding comes with the fix for your host and a prompt for your AI tool.
$19 once, including 20 runs over 30 days so you can fix things and check again.

Questions
What does X-Content-Type-Options: nosniff do?
It tells the browser to trust the Content-Type your server sent instead of guessing from the file's contents. MDN: with nosniff the browser blocks a script or stylesheet whose type doesn't match, and for other responses "uses the supplied Content-Type as-is instead of examining the content", so for example a text/plain file isn't treated as HTML.
Can nosniff break my site?
Only if some file is served with the wrong Content-Type: a script that isn't sent as JavaScript, or a stylesheet that isn't text/css, is blocked. On Vercel, Netlify, Cloudflare and other modern hosts your built files already have the right types. If you see a MIME type error after adding it, the console names the file; fix that file's type or path rather than dropping the header.
Which value should I use?
nosniff. It's the only value the header has.
Can I set it in a meta tag?
Set it as an HTTP header. MDN documents it only as a response header, scanners (including ours) read the response headers, and the config is one line on every host above.
Is a missing X-Content-Type-Options header serious?
It's low severity on its own: our free check and GitLab's scanner both rate it low. It matters most if users can upload files that your domain serves back. It's also one of the first lines in most pen-test reports and security questionnaires, so fixing it saves you that conversation.
Does this need to be on every response or just the HTML page?
Every response is simplest and what scanners expect: GitLab's remediation is to set it "server wide", and the protection is about scripts, stylesheets and files, not only your HTML page. A catch-all path (/* or /(.*)) does that.
Sources
- MDN: X-Content-Type-Options header
- MDN: MIME type verification (practical security guide)
- OWASP: HTTP Headers Cheat Sheet
- GitLab DAST check 693.1: Missing X-Content-Type-Options: nosniff
- Helmet: X-Content-Type-Options default
- Cloudflare Pages: Headers (_headers file)
- Cloudflare Workers: Static assets headers
- nginx: add_header (always, inheritance)
- Apache: mod_headers (Header always set)