Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
Axios HTTP requests not sending to Fastify backend

I'm trying to send a simple get request to my fastify server with axios, but i keep getting this error in the terminal:

Network Error
at node_modules/axios/lib/core/createError.js:15:17 in createError
at node_modules/axios/lib/adapters/xhr.js:114:22 in handleError
at node_modules/react-native/Libraries/Network/XMLHttpRequest.js:600:10 in setReadyState
at node_modules/react-native/Libraries/Network/XMLHttpRequest.js:395:6 in __didCompleteResponse
at node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:189:10 in emit

The request works perfectly fine in postman though, so I thought it was cors related and installed fastify-cors but I'm still getting the same error.

Does anyone have any suggestions how to fix this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have to explicitly fetch from your ip address, not your localhost. I fixed this by doing axios.get('http://<myIPaddr>:<port>'),

I was also told on the Fastify github help page to explicitly have the Fastify server listen on host '0.0.0.0'

fastify.listen({ port: 5000, host: "0.0.0.0" })

Now everything works fine.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda