Replies: 2 comments 2 replies
-
|
this is an common problem in hono! |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
I fixed it... It was a silly issue. I did not know I needed to define the hostname in the serve function. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In my Hono server with Node.js I have this controller to a get method. The path to it is 'http://localhost:5000/api/products'
The Next.js data fetching function is this one:
The error is this:
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11413:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: Error: connect ECONNREFUSED ::1:5000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 5000
}
}
In Next.js, I can fetch the data successfully as a client function (useState and useEffect), but I can't with a server-side request, as it is described above. The request route doesn't require authentication, any user should be able to fetch the data.
Is important to remind that my Next.js front-end is not connected with Hono RPC. The server (Hono) and the client (Next.js) are in separate folders.
Well, my question here is how to connect an outside client to a Hono server. Thanks for helping!
Beta Was this translation helpful? Give feedback.
All reactions