AlexDicy
AlexDicy
CDCloudflare Developers
Created by AlexDicy on 2/24/2023 in #pages-help
_headers file is recognized but not working
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");
}
});
7 replies
CDCloudflare Developers
Created by AlexDicy on 2/24/2023 in #pages-help
_headers file is recognized but not working
Makes sense, thank you
7 replies
CDCloudflare Developers
Created by AlexDicy on 2/24/2023 in #pages-help
_headers file is recognized but not working
Ah. Now I see
7 replies
CDCloudflare Developers
Created by AlexDicy on 2/24/2023 in #pages-help
_headers file is recognized but not working
7 replies