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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: Allow custom headers on rewrites #547

Merged
merged 2 commits into from Sep 19, 2019
Merged

Conversation

RaeesBhatti
Copy link
Contributor

- Summary
DEPENDS ON: https://github.com/netlify/libredirect/pull/61
Fixes: #423

- Test plan

  • Have following in your netlify.toml:
[[redirects]]
  from = "/api/*"
  to = "/.netlify/functions/:splat"
  status = 200
  headers = {X-From = "Netlify"}
[build]
  functions = "functions/"
  • Have following in /functions/hello-world.js
exports.handler = function(event, context, callback) {
    callback(null, {
        statusCode: 200,
        body: JSON.stringify(event.headers),
    });
}

- Description for the changelog

  • Iterate through match.proxyHeaders and set them on request
  • Make sure functions and addonsrequests are properly routed after rewriting

- A picture of a cute animal (not mandatory but encouraged)
馃檲

@RaeesBhatti RaeesBhatti changed the title Raees/redirects headers Dev: Allow custom headers on rewrites Sep 18, 2019
@RaeesBhatti RaeesBhatti merged commit be6dc8b into master Sep 19, 2019
@RaeesBhatti RaeesBhatti deleted the raees/redirects-headers branch September 19, 2019 03:22
@oscartbeaumont
Copy link

Is this PR still functioning as I just recreated the demo above and am not seeing the x-from header?

@RaeesBhatti
Copy link
Contributor Author

@oscartbeaumont This has not been released on NPM yet. Have you tried after linking repo at this branch with npm link? Apologies for the confusion

@oscartbeaumont
Copy link

No, sorry I assumed this had been released. I tried linking the master branch (commands below) and could also not get it to work.

npm remove netlify-cli -g
git clone https://github.com/netlify/cli.git
npm link cli/ # This seems to npm install
netlify dev

@RaeesBhatti
Copy link
Contributor Author

It seems like this also depends on a new release of netlify-redirector which is not open-source. Please wait until that is released, this comment thread will be updated when it is.

@oscartbeaumont
Copy link

oscartbeaumont commented Sep 26, 2019

Ok, thanks for your help. Do you have an estimated timeframe?

@RaeesBhatti
Copy link
Contributor Author

@oscartbeaumont This change has been published today with the latest version of Netlify CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Headers are not passed when redirecting
3 participants