breeze-nuxt
breeze-nuxt copied to clipboard
fetch failed ()
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)
What version of node.js are you using? Make sure you are using the LTS version, not the latest one.
Related: https://github.com/unjs/ohmyfetch/issues/156
changing package.json to run "dev": nuxt dev --host 127.0.0.1 seems to be a janky fix temporarily.
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
I can confirm. I just downgrade my node version to 16 through nvm, then changed localhost to 127.0.0.1. It works fine.
I also encountered this problem.
Two solutions have been found, either one is taken on a case-by-case basis:
- add
ssr: falsetonuxt.config.ts. or - Rename file
plugins/auth.tsto →plugins/auth.client.ts
Related links:
- https://nuxt.com/docs/guide/directory-structure/plugins
- https://nuxt.com/docs/api/configuration/nuxt-config#ssr
This seems to be fixed in Node.js As per this comment, if you are facing this problem try updating your Node.js version.