javascriptreact-nativenestjscors-anywhere

How to link React Native (expo) app with Nest js?


After setting the nest js project and verifying all routes using insomnia I've tried enabling cors

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.enableCors()
  await app.listen(3001);

}
bootstrap();

but I still get Network Error

the problem seems like from the Nest js project (cors specifically) because I tryied linking the same nest js project with react js project and everything was going fine .

Otherwise,in react native when trying something like

const res = await axios.get("https://www.google.com/")
      .then(res => console.log(res.data))
      .catch(err => console.error(err));

i get all the data in the log


Solution

  • Try to use instead of the local address http://localhost:3001 your local IP address like: http://192.168.xxx.xxx:3001