Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Astro middleware breaks Content-Encoding on netlify #269

Open
1 task
docapi opened this issue May 27, 2024 · 0 comments
Open
1 task

Astro middleware breaks Content-Encoding on netlify #269

docapi opened this issue May 27, 2024 · 0 comments

Comments

@docapi
Copy link

docapi commented May 27, 2024

Astro Info

Astro                    v4.8.5
Node                     v20.11.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  netlify
Integrations             astro-robots-txt
                         @astrojs/alpinejs
                         astro-compress

Describe the Bug

Netlify normally compresses pages with Brotli ("Content-Encoding : br"). If middleware (middleware.ts) is used, e.g. to set security headers, compression no longer works.
Example for middleware.ts:

import { defineMiddleware } from "astro/middleware";

export const onRequest = defineMiddleware(async (context, next) => {
  const response = await next();

  response.headers.set("Referrer-Policy", "same-origin");

  return response;
});

What's the expected result?

Netlify continues to compress the pages

Link to Minimal Reproducible Example

This problem happen specifically on netlify so I cannot reproduce on stackblitz or others

Participation

  • I am willing to submit a pull request for this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants