the bff project works only with public key but not private

giovanezanardo0
PRO

3 months ago

this BFF service worked using a docker image with nodejs, I need it to communicate privately with the other services in the environment, when I test using the private network so in the environment variables BIGBANG_BASE_URL="imagem-react-bigbang.railway.internal" HEIMDALL_BASE_URL="httpimage-react-heimdall.railway.internal" does not work, it worked only when I use the public variables so BIGBANG_BASE_URL="http://hopper.proxy.rlwy.net:20856" HEIMDALL_BASE_URL="http://hopper.proxy.rlwy.net:50086".
why did it only work on the public network and not on the private one?

react-bff@1.0.0 dev > nodemon src/server.js [nodemon] 3.1.9 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting node src/server.js [BFF] HEIMDALL_BASE_URL (authMiddleware) = 'http://imagem-react-heimdall.railway.internal'; [BFF] HEIMDALL_BASE_URL (loginService) = 'http://imagem-react-heimdall.railway.internal'; [2025-05-10 14:24:11] INFO: Middleware de CORS configurado [2025-05-10 14:24:11] INFO: Rotas aplicadas [2025-05-10 14:24:11] INFO: BFF rodando em http://localhost:3000 [2025-05-10 14:24:27] INFO: Recebendo solicitação de login [2025-05-10 14:24:27] INFO: Requisição de login recebida [2025-05-10 14:24:27] INFO: Iniciando autenticação no Backend user_identifier: "will" [2025-05-10 14:24:27] ERROR: Erro ao autenticar no Backend error: { "message": "connect ECONNREFUSED fd12:a4d:57b0:0:a000:28:1a54:b415:80", "name": "Error", "stack": Error: connect ECONNREFUSED fd12:a4d:57b0:0:a000:28:1a54:b415:80 at AxiosError.from (/app/node_modules/axios/dist/node/axios.cjs:857:14) at RedirectableRequest.handleRequestError (/app/node_modules/axios/dist/node/axios.cjs:3169:25) at RedirectableRequest.emit (node:events:518:28) at eventHandlers.<computed> (/app/node_modules/follow-redirects/index.js:49:24) at ClientRequest.emit (node:events:518:28) at emitErrorEvent (node:_http_client:104:11) at Socket.socketErrorListener (node:_http_client:518:5) at Socket.emit (node:events:518:28) at emitErrorNT (node:internal/streams/destroy:170:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at Axios.request (/app/node_modules/axios/dist/node/axios.cjs:4258:41) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async exports.authenticate (/app/src/services/loginService.js:32:26) at async exports.handleLogin (/app/src/controllers/loginController.js:14:22) "config": { "transitional": { "silentJSONParsing": true, "forcedJSONParsing": true, "clarifyTimeoutError": false }, "adapter": [ "xhr", "http", "fetch" ], "transformRequest": [ ], "transformResponse": [ ], "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN",

Solved$10 Bounty

1 Replies

3 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 3 months ago


3 months ago

Hey giovanezanardo0, while I am unfamiliar with BFF, I believe that the issue is your private URL being configured incorrectly, mainly missing the port. The correct structure would be BACKEND_URL=http://${{api.RAILWAY_PRIVATE_DOMAIN}}:${{api.PORT}}, more on private networking using reference variables can be found here.

Additionally, it looks like you are using nodemon in production. This is not needed as it will add unnecessarily overhead for essentially nothing.


Status changed to Solved uxuz 2 months ago