next.js: Changing response status code in _error.js
changing response code in custom error page, not working.
This is content in pages/_error.js file.
import React from 'react'
function Error(props) {
return (
<div>
my custom page
</div>
)
}
Error.getInitialProps = ({ req, res, err }) => {
res.status = 200 // changing the response code here
return {}
}
but status is always goes as 404. any suggestion?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 17 (9 by maintainers)
Also noticing this issue. I can set headers in the error page, but not the status code.
I have also tried this but not getting the custom page
Custom Page
but getting this page
next js 404 page
This is code for _error.js
and calling error code
🙏 PLEASE TELL ANY WRONG I HAVE DONE IN CODE 🙏