commerce icon indicating copy to clipboard operation
commerce copied to clipboard

[SALEOR] BUILD ERROR OCCURED: Specified images.domain should be an array.

Open kyssaFarms opened this issue 2 years ago • 5 comments

As per the documents I changed the env variables

COMMERCE_PROVIDER=@vercel/commerce-saleor

NEXT_PUBLIC_SALEOR_API_URL=http://0.0.0.0:8000/graphql/ NEXT_PUBLIC_SALEOR_CHANNEL=default-channel

I then did yarn in the root folder.

After that i ran yarn dev in both the root folder as well as the /site/ folder and always get the same error.

next-commerce:dev: Error: Specified images.domains should be an Array of strings received invalid values (). next-commerce:dev: See more info here: https://nextjs.org/docs/messages/invalid-images-config next-commerce:dev: at assignDefaults (/Users/hargunsingh/Desktop/kyssa-farms/User-app/commerce/node_modules/next/dist/server/config.js:206:23) next-commerce:dev: at Object.loadConfig [as default] (/Users/hargunsingh/Desktop/kyssa-farms/User-app/commerce/node_modules/next/dist/server/config.js:439:16) next-commerce:dev: at async NextServer.loadConfig (/Users/hargunsingh/Desktop/kyssa-farms/User-app/commerce/node_modules/next/dist/server/next.js:116:22) next-commerce:dev: at async NextServer.prepare (/Users/hargunsingh/Desktop/kyssa-farms/User-app/commerce/node_modules/next/dist/server/next.js:98:24) next-commerce:dev: at async /Users/hargunsingh/Desktop/kyssa-farms/User-app/commerce/node_modules/next/dist/cli/next-dev.js:130:9 next-commerce:dev: error Command failed with exit code 1. next-commerce:dev: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. next-commerce:dev: Error: command finished with error: exit status 1

Am i doing something wrong or is this a possible bug?

kyssaFarms avatar Mar 14 '22 08:03 kyssaFarms

Hey! It looks like you're not passing the right data in your next.config.js file, could you show us what you're passing? You should be passing the CDN url of the images.

okbel avatar Mar 23 '22 15:03 okbel

Hey! It looks like you're not passing the right data in your next.config.js file, could you show us what you're passing? You should be passing the CDN url of the images.

I was having the same issue as this, but I added COMMERCE_IMAGE_HOST=127.0.0.1:8000 to my .env.local and that got past t hat so I can run it. (The COMMERCE_IMAGE_HOST is not in the .env.template which is needed to run even the demo version.

However, once I get past that and go to the site, I get this new erorr:

error - ..\packages\saleor\dist\api\operations\get-all-products.js (24:0) @ CommerceAPICore.getAllProducts TypeError: Cannot read properties of null (reading 'products') 22 | if (featured) { 23 | var ref, ref1;

24 | const products = ((ref = data.collection.products) === null || ref === void 0 ? void 0 : (ref1 = ref.edges) === null || ref1 === void 0 ? void 0 : ref1.map(({ node: p })=>normalizeProduct(p) 25 | )) ?? []; 26 | return { 27 | products

RyanTamulevicz avatar Apr 26 '22 21:04 RyanTamulevicz

Can also add that after doing what @RyanTamulevicz did with adding COMMERCE_IMAGE_HOST, I'm getting the same error as well.

streetmapp avatar May 01 '22 20:05 streetmapp

Hey there! I had the same issue from @RyanTamulevicz. I set the COMMERCE_IMAGE_HOST=localhost as I'm using macOS, and on the file site/pages/index.tsx, I changed the featured param to false, which worked for me.

dilvane avatar Jun 02 '22 11:06 dilvane

I've had all the issues above at different points. Managed to fix them all one way or another except for the null collection issue but reading the comment from dilvane gave me the idea of what could be wrong. Think it's fair to say that the landing page should list only the featured products and not everything so keep featured as true in site/pages/index.tsx. The real issue with listing the featured products is the collection id for featured collection hardcoded in the package.

You need to login to the dashboard and get the collection id form it's url

Screen Shot 2022-06-11 at 1 03 13 pm

In my case it is Q29sbGVjdGlvbjoz

Then go to this path packages/saleor/src/api/operations/get-all-products.ts and fix the category id.

Screen Shot 2022-06-11 at 1 09 42 pm

Rebuild the package by running this from project root yarn workspace @vercel/commerce-saleor build

And Bob's your uncle from there. Hope this helps someone.

amir-zahedi avatar Jun 11 '22 03:06 amir-zahedi

add COMMERCE_IMAGE_HOST in env.local

Example:

COMMERCE_PROVIDER=@vercel/commerce-saleor
NEXT_PUBLIC_SALEOR_API_URL=https://vercel.saleor.cloud/graphql/
NEXT_PUBLIC_SALEOR_CHANNEL=default-channel
COMMERCE_IMAGE_HOST=vercel.saleor.cloud

iqfareez avatar Mar 23 '23 09:03 iqfareez

Hey there! Thank you for opening this issue. We have decided to take Next.js Commerce in a new direction and will be closing out current PRs and issues due to this change. Please see this PR for more details: https://github.com/vercel/commerce/pull/966

leerob avatar Apr 18 '23 02:04 leerob