Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medusa Development Resources: Issue in Next.js Starter - Medusa Development Resources - Fetch error after following basic install steps #10124

Open
1 of 2 tasks
siberian-devsky opened this issue Nov 15, 2024 · 2 comments

Comments

@siberian-devsky
Copy link

What Medusa version and documentation are you using?

v2

Preliminary Checks

Issue Summary

I did my due diligence for finding a dupe - none found.

Screenshot 2024-11-15 at 15 23 40

-= STEPS TO REPRO =-

  1. git clone https://github.com/medusajs/nextjs-starter-medusa -b v2 my-medusa-storefront
  2. cd my-medusa-storefront
  3. npm install
  4. mv .env.template .env.local
  5. npm run dev
[][v2] jeff@Mac
/Users/Jeff/code/node/nextjs/my-medusa-storefront01
$ npm run dev

> [email protected] dev
> next dev -p 8000

  ▲ Next.js 14.2.15
  - Local:        http://localhost:8000
  - Environments: .env.local

 ✓ Starting...
 ✓ Ready in 1626ms
 ✓ Compiled /src/middleware in 398ms (89 modules)
 ⨯ src/middleware.ts (22:31) @ fetch
 ⨯ fetch failed
  20 |   ) {
  21 |     // Fetch regions from Medusa. We can't use the JS client here because middleware is running on Edge and the client needs a Node en
> 22 |     const { regions } = await fetch(`${BACKEND_URL}/store/regions`, {
     |                               ^
  23 |       headers: {
  24 |         "x-publishable-api-key": PUBLISHABLE_API_KEY!,
  25 |       },
 ○ Compiling /_error ...
 ✓ Compiled /_error in 1186ms (254 modules)
 GET / 404 in 4ms
 ○ Compiling /_not-found ...
 ⚠ Fast Refresh had to perform a full reload due to a runtime error.
 ⨯ src/middleware.ts (22:31) @ fetch
 ⨯ fetch failed
  20 |   ) {
  21 |     // Fetch regions from Medusa. We can't use the JS client here because middleware is running on Edge and the client needs a Node en
> 22 |     const { regions } = await fetch(`${BACKEND_URL}/store/regions`, {
     |                               ^
  23 |       headers: {
  24 |         "x-publishable-api-key": PUBLISHABLE_API_KEY!,
  25 |       },
 ✓ Compiled /_not-found in 7.4s (4360 modules)
 GET / 404 in 2ms
 ⚠ Fast Refresh had to perform a full reload due to a runtime error.
 ⨯ src/middleware.ts (22:31) @ fetch
 ⨯ fetch failed
  20 |   ) {
  21 |     // Fetch regions from Medusa. We can't use the JS client here because middleware is running on Edge and the client needs a Node en
> 22 |     const { regions } = await fetch(`${BACKEND_URL}/store/regions`, {
     |                               ^
  23 |       headers: {
  24 |         "x-publishable-api-key": PUBLISHABLE_API_KEY!,
  25 |       },
 ⨯ src/middleware.ts (22:31) @ fetch
 ⨯ fetch failed
  20 |   ) {
  21 |     // Fetch regions from Medusa. We can't use the JS client here because middleware is running on Edge and the client needs a Node en
> 22 |     const { regions } = await fetch(`${BACKEND_URL}/store/regions`, {
     |                               ^
  23 |       headers: {
  24 |         "x-publishable-api-key": PUBLISHABLE_API_KEY!,
  25 |       },
 GET / 404 in 1ms

How can this issue be resolved?

...

Are you interested in working on this issue?

  • I would like to fix this issue
@siberian-devsky
Copy link
Author

UPDATE:
I resolved the node issue you see in the yellow square in the original screenshot but I hit the same server exception. I am going to try the other method: npx create-medusa-app@latest.
Screenshot 2024-11-15 at 15 31 19

@ahmednabil310
Copy link

Are you sure your back end is running? You will get this error if your back-end is not working on localhost:9000 as specified in the environment variable:
NEXT_PUBLIC_MEDUSA_BACKEND_URL=http://localhost:9000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants