Skip to content

gatsby-adapter-netlify not generating headers for redirects #38538

@techfg

Description

@techfg

Preliminary Checks

Description

The gatsby-adapter-netlify is not generating HTTP headers defined in gatsby-config if the route is a redirect route.

Redirect routes support headers as defined in IRedirectRoute.

Based on this comment this appears to be functionality that is not yet implemented but with no "stock" way to "opt-out" of the netlify adapter when building and running on Netlify, this should likely be addressed sooner than later.

Reproduction Link

https://codesandbox.io/p/sandbox/gatsby-adapter-netlify-redirect-headers-missing-82qlk9?file=%2Fpublic%2F_headers

Steps to Reproduce

  1. Go to repro on codesandbox
  2. View the public folder and open _headers file
  3. There is no header for the path /testpage, however other headers from gatsby-config are present

To re-create the scenario:

  1. Run clean task
  2. Run build task
  3. View _headers file in public folder

Expected Result

A X-PageName header should be defined in _headers for the route /testpage

/testpage/
  X-PageName: TestPage

Actual Result

The X-PageName header for /testpage is not in the _headers file.

Environment

System:
    OS: Linux 6.1 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (2) x64 AMD EPYC
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 18.17.1 - ~/.local/state/fnm_multishells/2521_1694238260312/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.7 - ~/.local/state/fnm_multishells/2521_1694238260312/bin/npm
  npmPackages:
    gatsby: ^5.8.1 => 5.12.4
    gatsby-adapter-netlify: ^1.0.0 => 1.0.0

Config Flags

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: triage neededIssue or pull request that need to be triaged and assigned to a reviewertype: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions