gatsby: Previews URL don't persist across builds with gatsby-source-wordpress

Preliminary Checks

Description

When you generate preview for a page or post via Wordpress, Gatsby generates a preview URL

screenshot-2022-07-19-21-03-10@2x

Eg.

https://preview-{yoursitename}.gtsb.io/generated-preview-path/post/2171/

This URL is a temporary path.

Based on @KyleAMathews feedback

it needs to create a redirect once there's a real url

https://github.com/gatsbyjs/gatsby/blob/b653c7b32e8b0e82f581f1a4586a819999117734/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js#L392

Reproduction Link

https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-wordpress

Steps to Reproduce

  1. Use a gatsby-source-wordpress example
  2. Integrate it with WP and Gatsby Cloud
  3. Create a post and press preview in Wordpress
  4. Copy url
  5. Wait few days or just go to Gatsby Cloud -> CMS Preview and press Restart preview
  6. Open url from step 4, this will result in 404 page

Expected Result

After you press Preview in WP, you should land on the page with a persistent URL that users could share between each other and it will either generate a new preview, or open the latest available version.

Actual Result

Preview url is throwing 404 error after rebuilds, or after some time.

Environment

System:
    OS: macOS 12.4
    CPU: (8) arm64 Apple M1
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.3.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 103.0.5060.114
    Safari: 15.5
  npmPackages:
    gatsby: ^4.7.0 => 4.7.0
    gatsby-alias-imports: ^1.0.6 => 1.0.6
    gatsby-plugin-google-tagmanager: ^4.13.0 => 4.13.0
    gatsby-plugin-image: ^2.9.1 => 2.9.1
    gatsby-plugin-manifest: ^4.9.1 => 4.9.1
    gatsby-plugin-mdx: ^3.9.1 => 3.9.1
    gatsby-plugin-postcss: ^5.9.0 => 5.9.0
    gatsby-plugin-react-helmet: ^5.9.0 => 5.9.0
    gatsby-plugin-sharp: ^4.9.1 => 4.9.1
    gatsby-plugin-sitemap: ^5.9.0 => 5.9.0
    gatsby-plugin-svgr-svgo: ^2.0.0 => 2.0.0
    gatsby-remark-copy-linked-files: ^5.9.0 => 5.9.0
    gatsby-remark-images: ^6.9.1 => 6.9.1
    gatsby-remark-prismjs: ^6.9.0 => 6.9.0
    gatsby-remark-responsive-iframe: ^5.9.0 => 5.9.0
    gatsby-remark-video: ^1.2.5 => 1.2.5
    gatsby-source-filesystem: ^4.9.1 => 4.9.1
    gatsby-transformer-sharp: ^4.9.0 => 4.9.0

Config Flags

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

@TylerBarnes thank you! It’s very sad that there is no work around for this. As I understand that issue exists in every CMS due to current Gatsby architecture. I’m just wondering how other users deal with this, since we get complains about that behavior from different clients.