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

gatsby-source-wordpress: update node unable to fetch media item due to missing domain #38827

Open
2 tasks done
darrelhong opened this issue Jan 27, 2024 · 0 comments
Open
2 tasks done
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby

Comments

@darrelhong
Copy link

Preliminary Checks

Description

After adding a new media item or updating a post with media item, gatsby will try to source updated nodes. However, somewhere in the update node process, it is removing the domain name from the media item urls and keeping the path only, therefore when it tries to fetch the node, a not valid URI error occurs.

error

This breaks both local development and incremental builds.

I noticed that the the ensureSrcHasHostname function has hard-coded logic to add back the domain name, but only if the path starts with wp-content. If i modify this to suit the path to my uploads folder, it works. I believe that the plugin is removing the domain name as the graphql always responds with full URLs and I am not sure why there is a guard in place to add back the domain name, but only for certain hardcoded paths.

I'm wondering whether the best fix is to find out where the domain name is being dropped and preventing that, or allowing custom prefix paths for media items, perhaps in a config.

Reproduction Link

export const ensureSrcHasHostname = ({ src, wpUrl }) => {

Steps to Reproduce

  1. Setup Gatsby site + WordPress with WPGatsby and WPGraphQL plugin
  2. Configure media items prefix path to start with something other than wp-content.
  3. Run gatsby develop
  4. Create a post and add/edit a media item.

...

Expected Result

Fetch media and create/update node

Actual Result

Error occurs when trying to update nodes

Environment

environment agnostic

Config Flags

No response

@darrelhong darrelhong added the type: bug An issue or pull request relating to a bug in Gatsby label Jan 27, 2024
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

1 participant