Next.js Discord

Discord Forum

Content-Encoding entity is not present in the public directory PDF files' response header.

Answered
Bengal posted this in #help-forum
Open in Discord
BengalOP
I'm working on some SEO issues regarding my website, and one of these issues is that my PDF files are uncompressed according to the auditing tool. They should be compressed, however, they are missing the content-encoding header to indicate they are. How can I add this header to files served in the public directory?
Answered by Bengal
Fixed by:
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  async headers() {
    return [
      {
        source:
          "/(algemene-voorwaarden|deelnamebewijs-afbouwborg-STRAK-Bouwgroep).pdf",
        headers: [
          {
            key: "Content-Encoding",
            value: "gzip",
          },
        ],
      },
    ];
  },
};

module.exports = nextConfig;
View full answer

1 Reply

BengalOP
Fixed by:
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  async headers() {
    return [
      {
        source:
          "/(algemene-voorwaarden|deelnamebewijs-afbouwborg-STRAK-Bouwgroep).pdf",
        headers: [
          {
            key: "Content-Encoding",
            value: "gzip",
          },
        ],
      },
    ];
  },
};

module.exports = nextConfig;
Answer