[Hydrogen][Storefont] Cannot redirect to checkout page, got CORS error.

[Hydrogen][Storefont] Cannot redirect to checkout page, got CORS error.

Puttaku
Visitor
1 0 0

Hello.

I've created a new storefront with a "Hydrogen" sales channel.

However, I cannot redirect to the checkout URL, as I got this error on the console:

Puttaku_0-1741324203349.png

 

This is the code where I've call the "redirect" to the checkout's URL

 

export async function action({request, context}: ActionFunctionArgs) {
  const {storefront} = context;
  const formData = await request.formData();
  const input = JSON.parse((formData.get('product') as string) || '');

  const result = await storefront.mutate(CUSTOM_CART_MUTATION, {
    variables: {input},
  });

  const checkoutUrl = result?.cartCreate?.cart?.checkoutUrl;

  if (!checkoutUrl) return null;

  return redirect(checkoutUrl);
}

 

 

How could I fix this?

 

Note:

  • The Hydrogen's URL is: https://*******.myshopify.dev/
  • The "PUBLIC_STORE_DOMAIN" pattern is: *******.myshopify.com (This is the same URL as one that used in the "Online Store" sale channel)
Replies 0 (0)