Skip to content

[Bug]: Headers from next.config.js are not being used at all #1063

Closed
@jsardev

Description

@jsardev

Summary

The v4 release notes announce Full support for Next.js rewrites, redirects and headers. but I can't make the headers work on Netlify deployment.

It does work on next dev and next build && next start, but it does not work after deploying it on Netlify.

Steps to reproduce

  1. Add headers function to next.config.js
  2. Deploy the app on Netlify
  3. The custom headers are not there

A link to a reproduction repository

No response

Plugin version

4.0.0

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

Mac OS

Your netlify.toml file

`netlify.toml`
# Paste content of your `netlify.toml` file here

Your public/_redirects file

`_redirects`
# Paste content of your `_redirects` file here

Your next.config.js file

`next.config.js`
    ...
    headers: () => ([
        {
            source: "/fonts/(.*).otf",
            headers: [
                {
                    key: "Cache-Control",
                    value: "public, max-age: 31536000, immutable",
                },
            ],
        },
    ]),
    ...

Builds logs (or link to your logs)

Build logs
# Paste logs here

Function logs

Function logs
# Paste logs here

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions