-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Add support for setting a force redirect status in Netlify _redirects file #8521
Add support for setting a force redirect status in Netlify _redirects file #8521
Conversation
I think this is fine, I just don't like adjusting gatsby API docs for netlify specific redirect flag - this probably belong to netlify plugin |
So @pieh instead of adding to Gatsby |
Yeah, that would be great @RobertWSaunders! |
e928cbd
to
6bc3267
Compare
Updated! |
Thanks for filling out the PR so completely @RobertWSaunders! @pieh I'll let you merge this one just in case there's any more technical feedback |
Any updates on this @pieh? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @RobertWSaunders and sorry for wait
Holy buckets, @RobertWSaunders — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Awesome, thanks @pieh! |
* 'master' of github.com:gatsbyjs/gatsby: (72 commits) fix: fix wording in plopfile (gatsbyjs#8735) fix: navigateTo deprecation message (gatsbyjs#8745) Add deploying-to-heroku.md (gatsbyjs#8721) fix(docs): Link to instructions on adding to plugin library (gatsbyjs#8686) updated gatsby-plugin-remove-trailing-slashes docs to include link re… (gatsbyjs#8720) feat(www/starters): Add TypeScript and Contentful starter (gatsbyjs#8704) fix(docs): fix typos in template doc (gatsbyjs#8692) feat(www): change chevron direction on sticky responsive sidebar (gatsbyjs#8664) chore(release): Publish [integration] [cypress-gatsby] feat: Add Gatsby API support to our Cypress plugin (gatsbyjs#8641) chore(release): Publish fix(gatsby): add mjs config to webpack and resolve correctly (gatsbyjs#8717) feat(gatsby-plugin-netlify): add force option to createRedirect (gatsbyjs#8521) [www/starters] tweaks to fix DX for no GH token on www (gatsbyjs#8718) chore(release): Publish fix(gatsby-dev-cli): infer correct prefix from package path (gatsbyjs#8683) fix(www/starters): fix broken link to submission instructions (gatsbyjs#8715) chore(release): Publish feat(gatsby) : add createContentDigest helper (gatsbyjs#8687) feat: publish SendGrid case study blogpost (gatsbyjs#8592) ...
Proposed Change
Builds upon: #2890
When adding multiple domains in Netlify it can be nice to redirect domain aliases to your primary domain. In order to do so you need to add the correct redirect information into a
_redirects
file in the root of your site folder. Thegatsby-netlify-plugin
provides a nice way to automatically generate this file for us using thecreateRedirect
action, see the documentation for it here. However, it does not allow us to set a redirect status with theforce
option which is mentioned in the Netlify redirect documentation here. In order for domain aliases redirects and any other redirect that wants to override existing content in the path to work correctly we need to add the ability to set a forced redirect status in our_redirects
file. A forced status is denoted with an exclamation mark at the end of the status number. This change adds support forforce: true
to be passed intocreateRedirect
which will result in a redirect status code with an exclamation mark concatenated to it in the outputted_redirects
file.For example:
Will output:
How did you do this?
Accept the
force
option tocreateRedirect
and use it to build a redirect status.Why are you choosing this approach?
Improves functionality of
gatsby-netlify-plugin
!Any open questions you want to ask code reviewers?
Nope! 😎
List of changes:
createRedirect
redux action!force
argument tocreateRedirect
and build a redirect status from it.