Can I use route handlers to return specific http response?
Answered
British Shorthair posted this in #help-forum
British ShorthairOP
Hi, was wondering if you can use route handlers to return specific http responses. In my case I want to return a 410 status code, because I want to remove some pages from Google Search. Can't I just use a route handler to return that status code? If so, how?
Answered by Ray
sure you can do that
export function GET() {
return new Response("", { status: 410 })
}3 Replies
@British Shorthair Hi, was wondering if you can use route handlers to return specific http responses. In my case I want to return a 410 status code, because I want to remove some pages from Google Search. Can't I just use a route handler to return that status code? If so, how?
sure you can do that
export function GET() {
return new Response("", { status: 410 })
}Answer
btw if you want to return a custom status code for a particular page (
page.tsx), you can't. you have to use e.g. noindex nofollow to prevent google from indexing the page@Ray sure you can do that
ts
export function GET() {
return new Response("", { status: 410 })
}
British ShorthairOP
thanks @Ray