-
-
Notifications
You must be signed in to change notification settings - Fork 62
Decorate reply with nextRenderError #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Proxy to Next.js app.renderError - this method will render an appropriate error page based on the response status code.
| const reply = this | ||
| const { request } = reply | ||
|
|
||
| // set custom headers as next will finish the request | ||
| for (const [headerName, headerValue] of Object.entries(reply.getHeaders())) { | ||
| // Fastify sets content-length to `undefined` for error handlers, which is an invalid value | ||
| if (headerName === 'content-length' && headerValue === undefined) { | ||
| continue | ||
| } | ||
|
|
||
| reply.raw.setHeader(headerName, headerValue) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied from render above
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a unit test?
|
@mcollina |
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
I am unsure if the CI failures are a result of the changes. |
|
It might be, it seems code coverage got reduced. |
|
Ah yes, I will look into that. |
|
This should be ready for landing :-) |
Closes #435
Proxy to Next.js
app.renderError.The source code for
app.renderErrorat time of writing can be found here:app.renderError(public)app.renderErrorToResponse(private)This method will render an appropriate error page based on the response status code - the pathname does not affect the page rendering.
The page that will be rendered by this method can include:
/pages/_error.js/pages/404.js/pages/500.jsChecklist
npm run testandnpm run benchmarkand the Code of conduct