Skip to content

[shopify-api] GraphQL request with custom shop domain is not working #1868

Open
@McTom234

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

TL;DR: custom shop domains cannot be used with this library, due to a wrong redirect handling.

Prerequisites:

  • shop A has a custom domain a.com
  • you have valid credentials for shop A to make API requests (tested by using the Location 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 to GET, as this is the node-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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions