_headers file is recognized but not working

Hello, I'm using this _headers file:
https://:project.pages.dev/*
X-Robots-Tag: noindex
https://:project.pages.dev/*
X-Robots-Tag: noindex
It is recognized in the deployment, but every URL I try to open doesn't have the "X-Robots-Tag" header on the response. What can I do?
3 Replies
AlexDicy
AlexDicyOP2y ago
Walshy
Walshy2y ago
Looks like it’s being SSR’d https://developers.cloudflare.com/pages/platform/headers/ See note at top of page
AlexDicy
AlexDicyOP2y ago
Ah. Now I see Makes sense, thank you For future reference, if anybody wants to fix it and is using Nuxt, add a middleware in server/middleware/ with
import type {IncomingMessage} from "unenv/runtime/node/http";

export default defineEventHandler(async (event) => {
const req: IncomingMessage = event.node.req;
const hostname = (req.headers.host ?? "").split(":")[0];
if (hostname.endsWith(".pages.dev")) {
setResponseHeader(event, "X-Robots-Tag", "noindex");
}
});
import type {IncomingMessage} from "unenv/runtime/node/http";

export default defineEventHandler(async (event) => {
const req: IncomingMessage = event.node.req;
const hostname = (req.headers.host ?? "").split(":")[0];
if (hostname.endsWith(".pages.dev")) {
setResponseHeader(event, "X-Robots-Tag", "noindex");
}
});
Want results from more Discord servers?
Add your server