You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Being able to modify the response of a API or page in the middleware
Background
Currently, Nextjs' middleware only sits before page renders (only handling incoming requests), but there's no way in NextJS to modify the headers or body based on the app's response.
E.g. set a certain header in-case the app's page returns a certain HTTP response code. Or change the HTTP code to something else.
Proposal
Backwards compatible
Different middleware file for responses
Being able to export another middleware function for responses in the original middleware.ts
Breaking
NextResponse.next() actually returns the app's response
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Being able to modify the response of a API or page in the middleware
Background
Currently, Nextjs' middleware only sits before page renders (only handling incoming requests), but there's no way in NextJS to modify the headers or body based on the app's response.
E.g. set a certain header in-case the app's page returns a certain HTTP response code. Or change the HTTP code to something else.
Proposal
Backwards compatible
Breaking
Beta Was this translation helpful? Give feedback.
All reactions