X-Content-Type-Options header
nosniff stops browsers guessing a file's type from its bytes instead of trusting the server. What it prevents, and the one-line fix.
What it is
X-Content-Type-Options: nosniff tells the browser to trust the Content-Type header a server sends and stop guessing a resource's type from its content.
Without it, some browsers sniff a response's bytes and decide for themselves what kind of file it is, regardless of what the server declared.
Why it matters
MIME sniffing exists for compatibility with servers that mislabel files, but it opens a path where attacker-controlled bytes — uploaded as an image or a plain text file — get executed as script or CSS if the browser decides that's what they 'really' are.
nosniff removes that ambiguity: a response declared text/plain stays text/plain no matter what its body looks like.
How to fix it
with a reference docadd_header X-Content-Type-Options "nosniff" always;Header always set X-Content-Type-Options "nosniff"async headers() {
return [{
source: '/(.*)',
headers: [{ key: 'X-Content-Type-Options', value: 'nosniff' }]
}];
}/*
X-Content-Type-Options: nosniffRelated checks
3This is one of the 75 checks the scanner runs. See what we check for the full list, every severity weight, and how the score is computed from them.