medusajs / nextjs-starter-medusa

A performant frontend ecommerce starter template with Next.js 14 and Medusa.
https://next.medusajs.com/
MIT License
1.61k stars 431 forks source link

"store/regions" endpoint returns: Unexpected token '<', "<!DOCTYPE "... is not valid JSON #354

Open volfcan opened 1 month ago

volfcan commented 1 month ago

I've setup the backend and running, specify the .env files accordingly and trying to start the storefront and came across with this error. Any idea on how to fix that?

Error [SyntaxError]: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (file:///Users/volfcan/ZedProjects/nextjs-starter-medusa/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096)
    at successSteps (file:///Users/volfcan/ZedProjects/nextjs-starter-medusa/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096)
    at eval (file:///Users/volfcan/ZedProjects/nextjs-starter-medusa/node_modules/next/dist/compiled/edge-runtime/index.js:1:657096)
    at <unknown> (node:internal/process/task_queues:140:7)
    at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  middleware: true
}

I think this is originated from this line

const { regions } = await fetch(${BACKEND_URL}/store/regions, {

in the middleware.ts file

anubus298 commented 1 month ago

same here

anh-nguyen-mds commented 1 month ago

same

a-bertrand commented 1 month ago

Hello, i solve this by using the correct backend url in .env. i used the admin url (http://localhost:7001).

NEXT_PUBLIC_MEDUSA_BACKEND_URL=http://localhost:9000

kb-0912 commented 2 weeks ago

I got the same problem.