Replies: 2 comments 5 replies
-
I recognize I can do this with a proxy or nginx, but I'm wondering if theres a supported way of doing this natively |
Beta Was this translation helpful? Give feedback.
-
Create a custom server file in your Next.js project directory. You can name it server.js: const { createServer } = require('http'); const dev = process.env.NODE_ENV !== 'production'; app.prepare().then(() => {
}).listen(3000, (err) => { Run the custom server instead of the default Next.js server: and then navigate to http://localhost:3000/custom-route in your browser to see the modified HTML. |
Beta Was this translation helpful? Give feedback.
-
Summary
I'd like to have more control over the post processing of html - for instance, conditionally running my own CSS optimizer (instead of critters) based on the RequestContext.
Right now
postProcessHTML
frompackages/next/src/server/post-process.ts
is called before everyRenderResult
and only applies the hard coded options.Is there a place where we can hook into the rendered HTML and modify it before it's sent along?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions