No HTML compression via custom server & app.render()
See original GitHub issueBug report
Describe the bug
If you write custom server routes via app.render()
there is no gzip compression for the HTML document. I looked at the source code: the handleCompression()
fn is only called via the app.getRequestHandler()
. I guess this is not intended.
To Reproduce
- Clone the custom-server example (
yarn create next-app --example custom-server custom-server-app
) yarn build && yarn start
- Route to
http://localhost:3000/a
inspect HTML document response header via chrome dev tools orcURL
- There is no
Content-Encoding: gzip
response header 👎 - Route to index
http://localhost:3000/
inspect HTML document response header via chrome dev tools orcURL
Content-Encoding: gzip
response header available 👍
Expected behavior
- gzip compression of HTML documents rendered via
app.render()
- Response Header:
Content-Encoding: gzip
System information
- OS: macOS
- Version of Next.js: 9.5.2
- Version of Node.js: 12.18.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
How to access next.js rendered HTML via custom server
The compression library is initialized using the handleCompression function of the Next.js's Server object (which is accessible using the ...
Read more >Build a server-rendered React app with Next.js and Express
Next.js is a simple yet elegant approach to efficiently building server-rendered React apps with JavaScript. Get started with this tutorial.
Read more >Advanced Features: Custom Server - Next.js
A custom Next.js server allows you to start a server 100% programmatically in order to use custom server patterns. Most of the time,...
Read more >Static Sites | Render · Cloud Hosting for Developers
Deploy your static sites on Render in just a few clicks. Includes a global CDN, automatic TLS certificates, auto-deploys from Git, and custom...
Read more >Express Tutorial Part 7: Deploying to production
That makes deployment quite easy because you just need to concentrate on your web application and not any other server infrastructure.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve added test cases, @timneutkens.
I have one question - should
app.render
with/static
content also be compressed?@YichiZ exactly