bigcommerce / nextjs-commerce

Next.js Commerce
https://next-commerce-v2.vercel.app
MIT License
92 stars 81 forks source link

This Edge Function has crashed. Your connection is working correctly. Vercel is working correctly. #27

Closed francoisauger closed 1 year ago

francoisauger commented 1 year ago

Hi,

I've deployed the project on Vercel. I followed all token creation instructions and noted everything. I've added all env variables to Vercel, and also did the vercel env pull on my local setup.

No matter if I run the project locally (with pnpm dev) or if I deploy to Vercel, I get this error message on the page:

This Edge Function has crashed.
Your connection is working correctly.
Vercel is working correctly.

And these in the log: Request: [GET] / Message: [GET] [middleware: "middleware"] / reason=EDGE_FUNCTION_INVOCATION_FAILED, status=500, user_error=true

Request: [GET] / Message:

{
  status: 500,
  message: 'Unexpected token \'e\', "error code: 1016" is not valid JSON',
  query: '\n  query getEntityIdByRoute($path: String!) {\n    site {\n      route(path: $path) {\n        node {\n          __typename\n          ... on Product {\n            entityId\n          }\n          ... on Category {\n            entityId\n          }\n          ... on Brand {\n            entityId\n          }\n          #  NOTE: this API is still not public\n          ... on NormalPage {\n            entityId\n          }\n          ... on ContactPage {\n            entityId\n          }\n          ... on RawHtmlPage {\n            entityId\n          }\n          # TODO: use it later on\n          # ... on Blog {\n          #   name\n          #   id\n          # }\n        }\n      }\n    }\n  }\n'
}

Any help would be extremely appreciated!

Thank you

francoisauger commented 1 year ago

Sorry, I found my issue was that I replaced the BIGCOMMERCE_CANONICAL_STORE_DOMAIN by the one listed on my channel site "canonical" URL.

I fixed it by using the provided ENV var provided in the .env.example file:

BIGCOMMERCE_CANONICAL_STORE_DOMAIN="mybigcommerce.com"
BIGCOMMERCE_API_URL="https://api.bigcommerce.com"
BIGCOMMERCE_CDN_HOSTNAME="*.bigcommerce.com"