Skip to content

Commit

Permalink
asd
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop committed Dec 12, 2024
1 parent 6b7c6b4 commit 6c54316
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/myproject/functions/echo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ export default (req: Request, res: Response) => {
res.setHeader('Content-Encoding', 'gzip')
res.setHeader('Content-Type', 'application/json')

const compressedResponse = zlib.gzipSync(JSON.stringify(response)).toString('base64')

res.send(compressedResponse)
if (req.headers['accept-encoding'].includes('gzip')) {
if (req.headers['host'] === 'local.functions.local.nhost.run') {
const compressedResponse = zlib.gzipSync(JSON.stringify(response))
res.send(compressedResponse)
} else {
const compressedResponse = zlib.gzipSync(JSON.stringify(response)).toString('base64')
res.send(compressedResponse)
}
} else {
res.send(response)
}
}

0 comments on commit 6c54316

Please sign in to comment.