thomasKn / astro-shopify

A lightweight and powerful ecommerce starter theme to build headless Shopify storefronts with Astro.
https://astro-shopify.frontvibe.com
MIT License
332 stars 99 forks source link

shopifyShop name or url? #24

Closed silveltman closed 1 year ago

silveltman commented 1 year ago

First of all, awesome work!

for the .env file, should shopifyShop be the name or the url? So "my-shop" or "my-shop.myshopify.com"? I unfortunately get an error for both of them.

Error using name:

 error   fetch failed
  File:
    C:\Users\silve\Documents\web-dev\astro\astro-shopify\C:\Users\silve\Documents\web-dev\astro\astro-shopify\node_modules\undici\index.js:109:13
  Stacktrace:
TypeError: fetch failed
    at fetch (C:\Users\silve\Documents\web-dev\astro\astro-shopify\node_modules\undici\index.js:109:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async makeShopifyRequest (/src/utils/shopify.ts:38:20)
    at async Module.getProducts (/src/utils/shopify.ts:51:16)
    at async eval (C:\Users\silve\Documents\web-dev\astro\astro-shopify\src\pages\index.astro:20:20)
    at async renderPage (file:///C:/Users/silve/Documents/web-dev/astro/astro-shopify/node_modules/astro/dist/runtime/server/render/page.js:91:30)
    at async renderPage (file:///C:/Users/silve/Documents/web-dev/astro/astro-shopify/node_modules/astro/dist/core/render/core.js:81:20)
    at async renderPage (file:///C:/Users/silve/Documents/web-dev/astro/astro-shopify/node_modules/astro/dist/core/render/dev/index.js:108:10)
    at async handleRoute (file:///C:/Users/silve/Documents/web-dev/astro/astro-shopify/node_modules/astro/dist/vite-plugin-astro-server/route.js:152:20)
    at async run (file:///C:/Users/silve/Documents/web-dev/astro/astro-shopify/node_modules/astro/dist/vite-plugin-astro-server/request.js:46:14)

  Cause:
Error: getaddrinfo ENOTFOUND fulldev-storefront
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)

Error using url:

 error   Expected object, received null

Reproduction:

  1. Clone repo
  2. Add .env
  3. run yarn install
  4. run yarn dev

Hope you can help :)

thomasKn commented 1 year ago

Hi @silveltman,

Thanks for the feedback!

I just updated the .env.example file to make it easier for everyone. The shopifyShop var should be your-store.myshopify.com.

I tried using yarn and everything works on my side.

Do you have products listed in your store? Shopify graphQL API returns null if no ressource is found.

silveltman commented 1 year ago

Thanks @thomasKn !

I tried npm and pnpn too, but get the same error. The hard thing is that the error gives very little info.

I do have product in my store. In fact, I just openend a development store with test products. So now I'm thinking about it, here some updated reproduction steps:

  1. Go to your Shopify partner dashboard
  2. Create a new development store
  3. Be sure to select "for testing" on the radio input, instead of "for client"
  4. Click "create with test products" 5 previously mentioned steps...

Hope this helps! :)

thomasKn commented 1 year ago

@silveltman Did you try adding images to your products? I'm pretty sure the issue is related to Zod. The schema utility doesn't parse Shopify images as optional. Let me know about the images but I'll make a PR to handle products with no image anyway.

silveltman commented 1 year ago

The demo store provides products including images, so I don't think that's the problem here.

thomasKn commented 1 year ago

@silveltman do you mind sharing your Storefront API access scopes? Also, do you use both Public and Private access tokens in your .env?

thomasKn commented 1 year ago

@silveltman I just created a new store with sample data and everything works on my side. image

I also used the Shopify Headless app to create public and private tokens as follow: image

By default, the headless app uses all scopes and gives every permissions.

Have you tried the latest version of the main branch?