-
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 createRedirects action and Netlify support #2185
Conversation
…sby-plugin-netlify'
@pk-nb hey! we added support for redirects to your netlify plugin. In so doing, the "netlify-headers" title didn't make as much sense so we renamed it to |
Deploy preview ready! Built with commit 9020566 |
Hmm just realized we will need to do client side redirects still in production. E.g. handling your blog redirect use case. |
You mean for non-Netlify use cases? |
Rats! I tried integrating with the new plugin in facebook/react/pull/10771 and the redirect doesn't seem to work. https://deploy-preview-10771--reactjs.netlify.com/blog.html I'll look into it. 😦 Edit 1: Looks like Edit 2: Based on my console logging, it looks like |
Looks like a bad version of |
Maybe you can re-publish after building- let me know and I'll update the version and confirm the fix on my end. |
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.
Cool, thanks for letting me know!
const { redirects } = store.getState() | ||
|
||
await buildHeadersProgram(pluginData, pluginOptions) | ||
await createRedirects(pluginData, redirects) |
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.
Maybe this could be a promise.all, so they can run in parallel instead of series?
}) | ||
|
||
return writeFile(publicFolder(`_redirects`), data.join(`\n`)) | ||
} |
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.
Maybe we could add a plugin option to disable this as well?
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.
Is there any harm in writing an empty _redirects
file? Or are you concerned that we might override an existing one? (Guess it would be worth checking to see if we should append vs write.)
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.
Right—someone might want to make one by hand through the static folder rather than go through generation in this plugin.
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.
I'll create a follow-up PR.
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.
Done in PR #2191
Yeah, it's missing a .npmignore file. Adding and publishing. |
Yeah showing up now https://unpkg.com/gatsby-plugin-netlify@1.0.3/gatsby-node.js |
Thanks Kyle! |
Thanks @bvaughn for this feature, we can now create plugins for every hosting software. |
This is done in support of the new React website.
Example usage
Temporary redirect
Permanent redirect