-
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
Gatsby-source-wordpress not able to fetch image behind basic authenticate WordPress source #35151
Comments
Hi! Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it. If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look. Thanks for using Gatsby! 💜 |
Hi @LekoArts, while I can create a minimal reproduction of the build, what's the best way to include WordPress source and basic authentication requirement to reproduce this bug? |
I have the same issue after upgrading gatsby-source-wordpress to the latest version 6.10.0. |
I'm having a similar issue. I'm patching gatsby-source-wordpress to include an Authorization header, it's working fine in versions up to 6.9.0, in 6.9.1 and 6.10.0 it's not working with the same issue given by OP. GraphQL is fetched ok but images are not. I thought the "update dependency node-fetch to ^2.6.7 for gatsby-source-wordpress" change in 6.7.0 could have been responsible since that is stripping authorization headers under certain circumstances but that is working fine. |
Hey everyone, a reproduction of this will go a long way. I tried to reproduce this recently and wasn't able to so it's possible it's something specific to only some sites. |
Hi @TylerBarnes, I have replicated the official gatsby WordPress starter, and tried it with a fresh WP install on WPEngine behind htaccess password protection. Add a placeholder image to the hello-world post and came across with the following error. https://github.com/hazuremon/gatsby-starter-wordpress I have test that it built successfully before adding in password protection, and also built successfully by running gatsby-source-wordpress: 6.9.1 with htaccess password. The difference I notice is towards image processing step where before 6.10.0, it is using gatsby-plugin-sharp for image process where it switched to gatsby.image_cdn on the newest version.
UNHANDLED REJECTION Unable to fetch: Reason: Response code 401 (Unauthorized) Fetch details: |
+1 on this error. I'm running Nginx which is handling all auth, in contrast to WP handling anything or any Apache .ht dir level stuff. This affects my current project so I can test. |
Hi @LekoArts, will you be able to connect to a wordpress source with basic authentication to test the minimal built? Otherwise, what will be the best way to provide these information? |
Ok, I am fairly certain that this commit broke it: fe29c01 Previously the files were downloaded like this adding the auth headers now the files appear to be downloaded via fe29c01#diff-1505effea6d8cc135677ea127439e5777ee2a7e397447f647a3ee3ec797d4920R596 which appears not to accept auth headers. |
@wardpeet @TylerBarnes as both of you were involved in this change and it affects all wordpress users with a htaccess file, I would appreciate a timely response. |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
This is still a problem and no one in gatsby seems to care. Very frustrating. |
@rburgst it seems you've figured out the issue? Could you prepare a PR with a fix? |
Call me old fashioned, but I feel a bit offended if Gatsby itself broke the feature and then rely on the community to pick up the pieces. Its not that this is difficult to reproduce, just grab a new wordpress docker container, add the following
and the following
This will give you a wordpress with basic authentication of Judging from my past experience trying to get PRs through on the gatsby project, it was a quite slow experience (see, #31652, #28093). I am not sure I have the energy in the coming weeks to attempt something like this again. |
@rburgst @KyleAMathews the integrations team at Gatsby has this bug scheduled as part of our current 2 week sprint. I'll keep yall updated as we make progress. |
@rburgst I apologize you've had a poor experience before writing PRs. That's not our goal. I'll take responsible for getting the remark one in tomorrow. I hope you'll give contributing a go again in the future and have a better experience. |
Hi @rburgst 👋 As you pointed out, the issue is with Unfortunately though, this isn't suitable for production since it would expose credentials directly in image urls which can get logged, etc in hosting. Before I get to a proposed solution, it's important to mention that Gatsby uses
The first part is the simplest part and I am planning to implement it this week so that you and other users with WP instances behind http basic auth can get unblocked. The second one is a little trickier and with our other work in flight will probably get started within the next couple weeks. I'll tag you here when I have a PR and or release out for the first fix and then try and keep you updated about the second one too. Hope this helps! |
I am mainly interested in variant 1 as we currently dont use gatsby image cdn. However, I dont understand, why you cannot simply pass the auth headers to |
@rburgst you're right that that's what # 1 will entail. Because of that it should be easier to implement than # 2 where we need to figure out where to store auth headers. |
@rburgst What @TylerBarnes said! While we could just pass the auth as args to
That said, if we just pass the auth header data as args to |
@rburgst Update: we are planning on implementing a fix to make this work when Image CDN is disabled within the next two weeks. |
@rburgst I haven't followed the reproduction steps in that one yet - but I'd assume that it isn't trying to fetch images behind basic auth since it's using this WP demo instance: https://github.com/gatsbyjs/gatsby-starter-wordpress-blog/blob/main/gatsby-config.js#L31. That said, I don't think this will fix that other issue unfortunately. |
Any news on this? |
There is indeed! That PR is close to being merged. If you need a fix today you can try these canary versions:
Make sure the versions are exact in your Thanks for asking! EDIT: Looks like those canaries aren't working properly. I'm looking into it now, possibly I published them wrong |
very likely related #34387 |
@joernroeder looks related indeed. The original issue was separate but was resolved, the new issue is the same as this one. |
@rburgst: canaries published with a fix for this: #35151 (comment) The PR that fixes this should be merged soon and then go out with the next stable Gatsby release too |
For those who landed on this issue in the future, there are some breaking changes with upgrading to GatsbyCDN, it requires an update on graphql fields and settings in gatsby-config.js. You can find out more on the following page: https://support.gatsbyjs.com/hc/en-us/articles/4522338898579 |
Preliminary Checks
Description
Upgrading to latest gatsby-source-wordpress 6.10.0 has led to a build error of unable to fetch image error, with WordPress source that is behind basic authentication password protection.
Build is fine once it's downgraded back to gatsby-source-wordpress 6.9.1
Error message:
UNHANDLED REJECTION Unable to fetch:
[Image URL]
Reason: Response code 401 (Unauthorized)
Reproduction Link
Any basic auth protected WordPress
Steps to Reproduce
Expected Result
gatsby-source-wordpress MediaItem to fetch images and media without error
Actual Result
UNHANDLED REJECTION Unable to fetch:
[Image URL]
Reason: Response code 401 (Unauthorized)
Fetch details:
{
"attempt": 3,
"method": "GET",
"errorCode": "ERR_NON_2XX_3XX_RESPONSE",
"responseStatusCode": 401,
"responseStatusMessage": "Unauthorized",
"requestHeaders": {
"user-agent": "got (https://github.com/sindresorhus/got)",
"accept-encoding": "gzip, deflate, br"
},
"responseHeaders": {
"server": "nginx",
"date": "Wed, 16 Mar 2022 21:55:14 GMT",
"content-type": "text/html",
"content-length": "172",
"connection": "close",
"www-authenticate": "Basic realm="XXXXXXXX""
}
}
Environment
gatsby-source-wordpress 6.10.0 basic auth protected WordPress source
Config Flags
No response
The text was updated successfully, but these errors were encountered: