diff --git a/examples/myproject/functions/echo.ts b/examples/myproject/functions/echo.ts index f74da9bc..ba72a0a3 100644 --- a/examples/myproject/functions/echo.ts +++ b/examples/myproject/functions/echo.ts @@ -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) + } }