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

Add a GraphQL Proxy #2610

Closed
wants to merge 4 commits into from
Closed

Add a GraphQL Proxy #2610

wants to merge 4 commits into from

Conversation

blittle
Copy link
Contributor

@blittle blittle commented Oct 17, 2024

Add a new route available on all hydrogen sites that proxies GraphQL requests to Shopify.
For example, https://hydrogen.shop/api/2024-07/graphql proxies to https://hydrogen-preview.myshopify.com/api/2024-07/graphql.
This allows the browser to make SFAPI requests on the same domain.

Note, your server.ts needs to be updated to return a caught response:

try {
 ...
} catch (error) {
  if (!(error instanceof Response)) {
    console.error(error);
  }
-  return new Response('An unexpected error occurred', {status: 500});
+  return error instanceof Response ? error : new Response('An unexpected error occurred', {status: 500});
}

Copy link
Contributor

shopify bot commented Oct 17, 2024

Oxygen deployed a preview of your bl-add-gql-proxy branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
classic-remix ✅ Successful (Logs) Preview deployment Inspect deployment October 17, 2024 9:33 PM
sitemap ✅ Successful (Logs) Preview deployment Inspect deployment October 17, 2024 9:33 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment October 17, 2024 9:33 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment October 17, 2024 9:33 PM
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment October 17, 2024 9:33 PM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment October 17, 2024 9:33 PM

Learn more about Hydrogen's GitHub integration.

@blittle blittle closed this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant