'Return 404 status from 404.js/.tsx page
Created a simple 404.js page
import React from 'react'
import Error from 'next/error'
export default function Page404() {
return <Error statusCode={404} />
}
In [[...page]].tsx:
export async function getStaticPaths() { ... }
export async function getStaticProps({ ... } : StaticProps) {
...
if (!page) {
return {
notFound: true,
}
}
...
}
If I enter some dummy URL, error page is shown, but http status is 200. How can I change it to 404?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
