Open flowersayo opened 1 year ago
-> 해결안됨
android:usesCleartextTraffic="true"
-> 안됨
This worked for me because I was using my android mobile device to debug the application, The android device doesn't have any idea of the localhost on my computer. So if you are using your android device to debug use IP address instead of using localhost
172.30.1.61
(예시) 로컬호스트 서버의 포트가 4000, 안드로이드 에뮬레이터의 포트번호가 8081일 경우
react-native run-android 로 에뮬레이터를 실행시킨다.
에뮬레이터가 실행된 상태로 터미널에 다음과 같은 명령어를 입력한다.
adb -s 에뮬레이터이름 reverse tcp:포트번호 tcp:포트번호 (예시)
adb -s emulator-5554 reverse tcp:4000 tcp:4000
localhost 변경
react native는 앱을 구현하는 것이기 때문에 애뮬레이터가 필요하다. 하지만 애뮬레이터는 컴퓨터 안에 또 다른 가상 디바이스에서 켜진 것이기 때문에 주소에 localhost로 쓰면 접근할 수 없다. 따라서, localhost 대신 애뮬레이터의 IP주소를 넣어야 한다.
∴ localhost(127.0.0.1):port => 10.0.2.2:port
※ 이 방법으로 문제를 해결했다.
상황
Axios 요청을 보내면 Network Error 500 이 발생합니다. 찾아보니 React-native 에서 axios 를 사용할때 종종 있던 이슈같습니다..!!