breeze-nuxt icon indicating copy to clipboard operation
breeze-nuxt copied to clipboard

fetch failed ()

Open Seyid-cmd opened this issue 3 years ago • 4 comments

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)

Seyid-cmd avatar Oct 20 '22 11:10 Seyid-cmd

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

amrnn90 avatar Oct 21 '22 10:10 amrnn90

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

tao avatar Oct 28 '22 05:10 tao

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

prescience-data avatar Oct 28 '22 06:10 prescience-data

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

tao avatar Oct 28 '22 13:10 tao

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

LynxTR avatar Dec 26 '22 12:12 LynxTR

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:

  • https://nuxt.com/docs/guide/directory-structure/plugins
  • https://nuxt.com/docs/api/configuration/nuxt-config#ssr

sglazov avatar Feb 23 '23 20:02 sglazov

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

amrnn90 avatar Oct 10 '23 16:10 amrnn90