[shopify-api] GraphQL request with custom shop domain is not working #1868
Open
Description
Issue summary
Before opening this issue, I have:
- Upgraded to the latest version of the relevant packages
@shopify/*
package and version:11.6.1
- Node version:
20.11.1
- Operating system: Linux
- Set
{ logger: { level: LogSeverity.Debug } }
in my configuration, when applicable - Found a reliable way to reproduce the problem that indicates it's a problem with the package
- Looked for similar issues in this repository
- Checked that this isn't an issue with a Shopify API
- If it is, please create a post in the Shopify community forums or report it to Shopify Partner Support
TL;DR: custom shop domains cannot be used with this library, due to a wrong redirect handling.
Prerequisites:
- shop
A
has a custom domaina.com
- you have valid credentials for shop
A
to make API requests (tested by using theLocation
header of the redirect response)
The request to the GraphQL endpoint for shop A
on a.com/...
returns a 301
response and redirects to the shop's {shop}.myshopify.com
host. The default redirect handling of a 301
response in node-fetch is to set the request method to GET
. That results in a 404
response on the API (which I think is not optimal - see 405; but this is an API, not library issue).
Expected behavior
- The Shopify API should return a
308
for this request. - The Shopify API client should handle the redirect for GraphQL requests to use a
POST
request again.
Actual behavior
- The Shopify API returns a
301
, which resets the request method toGET
, as this is thenode-fetch
default.
Steps to reproduce the problem
I'd say, the explanation does a quite good job for this...
Other
This is partly a Shopify API issue. But the library should be able to handle this case (imo).
Metadata
Assignees
Labels
No labels