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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for client-side redirects in production #2227

Merged
merged 2 commits into from
Sep 25, 2017

Conversation

KyleAMathews
Copy link
Contributor

/cc @bvaughn

This PR also adds a flag to createRedirect "redirectInBrowser" which a user
must opt into for the redirect to be run in the browser. This is done as there
are many scenarios where people building sites with Gatsby might have hundreds
or thousands of redirects from legacy versions of the site, none of which
we'd want loaded into the browser.

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit 71f8f20

https://deploy-preview-2227--gatsbygram.netlify.com

@bvaughn
Copy link
Contributor

bvaughn commented Sep 25, 2017

Thanks for the cc! Will try to find time to look at this soon, but don't have it at the moment.

WRT #2226, I'm initially confused that the current behavior (in master) is different based on the absence/presence of a trailing slash though. Note to myself to figure out why that is when I later look at this PR.

Edit: Disregard. It looks like the trailing slash "fix" didn't work on prod after all, even though it did on the preview-built version of the site. I believe this was because we were using an <a> tag in one place and a Gatsby <Link> tag in another.

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, at a glance. Did not test it yet though. Will be happy to test it when a new version is released, provided #2225 does not block me from upgrading.

@bvaughn
Copy link
Contributor

bvaughn commented Sep 26, 2017

FYI, I updated the React site to gatsby@1.9.44 and changing our gatsby-node.js to:

// Blog landing page should always show the most recent blog entry.
createRedirect({
  fromPath: '/blog/',
  redirectInBrowser: true,
  toPath: newestBlogNode.fields.slug,
});

Works like a charm 😄 Thanks!

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.

None yet

3 participants