GithubHelp home page GithubHelp logo

codedredd / h3-compression Goto Github PK

View Code? Open in Web Editor NEW
61.0 1.0 2.0 155 KB

Adds compression to h3 requests (brotli, gzip, deflate)

License: MIT License

TypeScript 99.34% Vue 0.66%
brotli compression deflate gzip h3 nuxt3

h3-compression's People

Contributors

codedredd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

h3-compression's Issues

Compression with Nuxt swr cache

Environment

  • Operating System: Darwin
  • Node Version: v18.16.0
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: [email protected]
  • Builder: -
  • User Config: app, nitro, srcDir, runtimeConfig, extends, modules, ui, colorMode, googleFonts, fontMetrics, css, routeRules, telemetry, devtools, typescript
  • Runtime Modules: @nuxt/ui, @nuxtjs/fontaine@^0.4.1, @nuxtjs/google-fonts@^3.1.1, nuxt-og-image@^2.2.4, @linotype/nuxt@*
  • Build Modules: -

Reproduction

https://github.com/YannickArmspach/nuxt3-h3-compression

Describe the bug

Hello,

I try to activate compression with Nuxt cache without success.

Compression works fine by default in nuxt (ssr) with NitroPlugin integration:
image

But if I activate the nuxt cache (swr), the cache is returned but without compression:
image

Is there another solution (hook?) to also compress the cache returned by nuxt?

Additional context

No response

Logs

No response

Cannot read properties of undefined (reading 'startsWith')

Environment

  • Operating System: Linux
  • Node Version: v20.6.1
  • Nuxt Version: 3.7.3
  • CLI Version: 3.9.0
  • Nitro Version: 2.6.3
  • Package Manager: [email protected]

Reproduction

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);
    });
});

Describe the bug

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)

Additional context

No response

Logs

No response

Nuxt 3 broken error page handling on direct URL call

Environment

  • Operating System: Darwin
  • Node Version: v20.9.0
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-k9tmde?file=README.md

Describe the bug

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.

Additional context

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.

Logs

No response

Can't get the response with aws-lambda preset

Environment

  • Operating System: Linux
  • Node Version: v20.10.0
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.0
  • Package Manager: [email protected]

Reproduction

Build nitro with "aws-lambda" preset

Describe the bug

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:

  • Accept-Ranges: bytes
  • Cache-Control: no-cache
    were added

And:

  • Vary: Accept-Encoding
    was changed to:
  • Vary: Accept-Encoding,accept-encoding

I didn't succeed to change theses so i don't know if is a part of the issue.

Additional context

No response

Logs

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.