amrnn90 / breeze-nuxt

An application / authentication starter kit frontend in Nuxt3 for Laravel Breeze.
MIT License
198 stars 33 forks source link

fetch failed () #3

Closed Seyid-cmd closed 1 year ago

Seyid-cmd commented 2 years ago

I have followed the instruction in the read me, but end up getting the error 500 "fetch failed ()". @at async Module.$larafetch (my-project-path-/utils/$larafetch.ts:33:12)

amrnn90 commented 2 years ago

What version of node.js are you using? Make sure you are using the LTS version, not the latest one.

tao commented 2 years ago

Related: https://github.com/unjs/ohmyfetch/issues/156

prescience-data commented 2 years ago

changing package.json to run "dev": nuxt dev --host 127.0.0.1 seems to be a janky fix temporarily.

tao commented 2 years ago

OK yeah, that seems to help.

Run nuxt with nuxt dev --host 127.0.0.1, make sure the env vars are all set to use 127.0.0.1 instead of localhost

// nuxt.config.js
runtimeConfig: {
  public: {
    backendUrl: 'http://127.0.0.1:8000',
    frontendUrl: 'http://127.0.0.1:3000',
  },
},

And on the Laravel app too so the CORS works

// .env
APP_URL=http://127.0.0.1:8000
FRONTEND_URL=http://127.0.0.1:3000
LynxTR commented 1 year ago

I can confirm. I just downgrade my node version to 16 through nvm, then changed localhost to 127.0.0.1. It works fine.

sglazov commented 1 year ago

I also encountered this problem.

Two solutions have been found, either one is taken on a case-by-case basis:

  1. add ssr: false to nuxt.config.ts. or
  2. Rename file plugins/auth.ts to → plugins/auth.client.ts

Related links:

amrnn90 commented 1 year ago

This seems to be fixed in Node.js As per this comment, if you are facing this problem try updating your Node.js version.