Issue making http call from application to external API

I have a Nuxt 3 app with a server route that is responsible for calling an external API: https://hacker-news.firebaseio.com/v0/item/${itemID}.json which works great locally and on render.com, but fails when deployed on dokploy (on hetzner cloud). It seems to be an issue with establishing a TLS connection:
bash
An error occurred while retrieving an individual story on the server
FetchError: [GET] "https://hacker-news.firebaseio.com/v0/item/41372017.json": <no response> fetch failed
...
[cause]: Error: Client network socket disconnected before secure TLS connection was established
at TLSSocket.onConnectEnd (node:_tls_wrap:1729:19)
at TLSSocket.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ECONNRESET',
path: undefined,
host: 'hacker-news.firebaseio.com',
port: 443,
localAddress: null
}
}
}
bash
An error occurred while retrieving an individual story on the server
FetchError: [GET] "https://hacker-news.firebaseio.com/v0/item/41372017.json": <no response> fetch failed
...
[cause]: Error: Client network socket disconnected before secure TLS connection was established
at TLSSocket.onConnectEnd (node:_tls_wrap:1729:19)
at TLSSocket.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ECONNRESET',
path: undefined,
host: 'hacker-news.firebaseio.com',
port: 443,
localAddress: null
}
}
}
Is there something that needs to be setup when I want to make calls to an external API from a service?
18 Replies
Siumauricio
Siumauricio9mo ago
Looks like is related to firebase, I never used firebase before, but probably you can add some whitelist ip or edit some firewall rules?
stefanVDW
stefanVDWOP9mo ago
Do you mean on the dokploy side or the firebase side? The clarify, the firebase URL i'm calling is an open firebase API for Hacker News and not something I have control over. See this as an example: https://hacker-news.firebaseio.com/v0/item/41372129.json
Siumauricio
Siumauricio9mo ago
are you using dockerfiles or nixpacks?
stefanVDW
stefanVDWOP9mo ago
GitHub
GitHub - StefanVDWeide/modern-orange: a modern Hacker News client b...
a modern Hacker News client built with Nuxt 3 and based on the official HN API - StefanVDWeide/modern-orange
GitHub
modern-orange/server/api/getIndividualStoryRest.post.ts at master ·...
a modern Hacker News client built with Nuxt 3 and based on the official HN API - StefanVDWeide/modern-orange
Siumauricio
Siumauricio9mo ago
got it, let me try
Siumauricio
Siumauricio9mo ago
No description
stefanVDW
stefanVDWOP9mo ago
I just pushed a fix! I added a fetch call to google just to make sure it works at all and that one succeeded
Siumauricio
Siumauricio9mo ago
did you added this env ? NIXPACKS_START_CMD="npm run preview"
stefanVDW
stefanVDWOP9mo ago
Turns out that making too many api calls is messing with TLS somewhere, either at the firebase side or dokploy, not sure No I have this as start command: NIXPACKS_START_CMD="node .output/server/index.mjs" As per the Nuxt docs
Siumauricio
Siumauricio9mo ago
hmmm probably that could be the issue
stefanVDW
stefanVDWOP9mo ago
But preview is not meant for production, no?
Siumauricio
Siumauricio9mo ago
or let me try, you are right that's the correct production start command
stefanVDW
stefanVDWOP9mo ago
At least not for nuxt
Siumauricio
Siumauricio9mo ago
yeah you are right, im not familiar with nuxt
stefanVDW
stefanVDWOP9mo ago
But the issue seems solved now I can make an example for Dokploy if you want! I work a lot with nuxt
Siumauricio
Siumauricio9mo ago
Would be awesome if you can do it
Siumauricio
Siumauricio9mo ago
we have this repo for examples https://github.com/Dokploy/examples
GitHub
GitHub - Dokploy/examples: Examples to deploy on Dokploy
Examples to deploy on Dokploy. Contribute to Dokploy/examples development by creating an account on GitHub.

Did you find this page helpful?