Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
fix: handle compression for custom-server render calls (vercel#16378) (
Browse files Browse the repository at this point in the history
…vercel#18891)

Co-authored-by: Radosław Grochowski <radoslaw.grochowski@grupawp.pl>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
  • Loading branch information
3 people authored May 7, 2021
1 parent 01fa703 commit ad3ebfc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/next/next-server/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,11 @@ export default class Server {
return this.handleRequest(req, res, parsedUrl)
}

// Custom server users can run `app.render()` which needs compression.
if (this.renderOpts.customServer) {
this.handleCompression(req, res)
}

if (isBlockedPage(pathname)) {
return this.render404(req, res, parsedUrl)
}
Expand Down
13 changes: 13 additions & 0 deletions test/integration/custom-server/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,17 @@ describe('Custom Server', () => {
expect(stderr).toContain('Cannot render page with path "dashboard"')
})
})

describe('compression handling', function () {
beforeAll(() => startServer())
afterAll(() => killApp(server))

it.each(['/', '/no-query'])(
'should handle compression for route %s',
async (route) => {
const response = await fetchViaHTTP(appPort, route)
expect(response.headers.get('Content-Encoding')).toBe('gzip')
}
)
})
})

0 comments on commit ad3ebfc

Please sign in to comment.