codedredd / h3-compression Goto Github PK
View Code? Open in Web Editor NEWAdds compression to h3 requests (brotli, gzip, deflate)
License: MIT License
Adds compression to h3 requests (brotli, gzip, deflate)
License: MIT License
Moving from unjs/nitro#1007
https://github.com/YannickArmspach/nuxt3-h3-compression
Hello,
I try to activate compression with Nuxt cache without success.
Compression works fine by default in nuxt (ssr) with NitroPlugin integration:
But if I activate the nuxt cache (swr), the cache is returned but without compression:
Is there another solution (hook?) to also compress the cache returned by nuxt?
No response
No response
import { useCompression } from 'h3-compression';
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('render:response', async (response, { event }) => {
if (!response.headers?.['content-type'].startsWith('text/html')) { // undefined response.headers?.['content-type']
return;
}
await useCompression(event, response);
});
});
I not see it any more, may be that case is registered when some errors is in nuxt config.
Cannot read properties of undefined (reading 'startsWith')
at (./server/plugins/compression.ts:9:1)
at ./node_modules/hookable/dist/index.mjs:48:66
at ./node_modules/hookable/dist/index.mjs:48:56
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at (./node_modules/nitropack/dist/runtime/renderer.mjs:29:5)
at async Object.handler (./node_modules/h3/dist/index.mjs:1630:19)
at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:1840:7)
No response
No response
Darwin
v20.9.0
3.8.2
3.10.0
2.8.1
[email protected]
-
devtools
-
-
https://stackblitz.com/edit/github-k9tmde?file=README.md
The error page in Nuxt 3 stops working with this plugin enabled. A normal invalid NuxtLink is working, but if you call something not existing manually from e.g. the browser bar. The 404 error is not handled by Nuxt anymore.
After removing the server plugin compression.ts this is working again.
I have linked a minimal demo on StackBlitz, but I had to download the project and use it locally to get the error. It could be related to how StackBlitz is handling the localhost URLs.
No response
Build nitro with "aws-lambda" preset
I tried h3-compression plugin with aws-lambda preset and I didn't manage to get it work, I tried to add some logging and the body seems well encoded.
But I never succeed to get a well formatted response, I get the error:
"No data found for the resource with given identifier"
I noticed some changes (with node-server preset) in the response headers:
And:
I didn't succeed to change theses so i don't know if is a part of the issue.
No response
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.