ndimatteo / HULL

💀 Headless Shopify Starter – powered by Next.js + Sanity.io
https://hull.dev
MIT License
1.36k stars 167 forks source link

"/api/shopify/product-update" issue vercel functions for product syncing - help please #107

Closed musaa-muhsen closed 1 year ago

musaa-muhsen commented 1 year ago

Hi, I'm just wondering please if you could help with the product syncing issue that I'm having so I'm aware you have to change or add products in order to trigger the webhook, however, I'm getting this error (shown below pic 1) on Vercel functions so no products are being added to Sanity. I've added the live URL also (shown below pic 2). Is there a setting not included maybe? Picture 3 is the .env settings for Vercel I thought I might add.

Also, the only thing I added to /studio .env.development and .env.production was SANITY_STUDIO_PREVIEW_SECRET as well, is this correct?

Once again a great project and any help would be much appreciated. Thanks

1)

Screenshot 2022-09-16 at 17 51 22

2)

Screenshot 2022-09-16 at 18 09 55

3)

Screenshot 2022-09-16 at 18 17 39
musaa-muhsen commented 1 year ago

I've checked several times now as well to see if everything is correct, including the Webhook API version but still no luck. I have gone through past GH issues to make sure that I'm not missing something.

I'm getting this error on the console as well a CORS error and graphQL 404 error as well.

Screenshot 2022-09-17 at 11 02 30
ndimatteo commented 1 year ago

Hey there @musaa-muhsen, sorry for the delay in getting back to you!

This is interesting and a bit hard to debug from your screenshots. Was this a manual or auto setup?

In your first screenshot, it appears that you're being denied access to read/write from Shopify in the sync function. Are you sure you added the correct Storefront API keys and added the correct API Scopes for each? (please check the setup instructions)

As for the last error you sent that shows a CORS error, I'm not sure what that's coming from, as there's no CORS settings for the Shopify side of things. That's only required for Sanity, ensuring that it can be accessed from different domains.

Let me know if you can confirm the above and if there's any other error logging you can share!

musaa-muhsen commented 1 year ago

Hi @ndimatteo ,

No worries thanks for getting back to me. I realised after the local version CORS wasn't set up but already did have it for the live version I did check the Storefront API key thoroughly several times but to no avail. It was driving me mad trying to figure it out so I ended up creating my own setup inspired by your own.

However, I was wondering if you could help me with something still please so I’m aware that you have a theme.liquid, I’m assuming this is for the account login side of things only? And portals to the “online store” I’m assuming? It would be great to know how you went about tackling the account part when you have a moment.

Thanks, M

ndimatteo commented 1 year ago

No problem @musaa-muhsen, I wish we could figure out what was causing you issues, I'm sure it was just a misconfiguration somewhere.

As for the theme.liquid file, that's to properly redirect to the headless storefront when one of the Shopify native product/collection URL paths is hit. It bypasses account-related paths so that those can still be handled through Shopify native.

Closing this for now, but if you end up going back to HULL for your headless setup and have questions feel free to open another issue!