I have a React Native (Expo go) frontend and Django based backend.
I have the django backend setup with some API endpoints, which I am trying to reach from frontend.
When using npx expo start --tunnel command instead of npx expo start command to launch the frontend, the web requests to the backend fail.
This is the full setup:
In django settings, I have these settings setup:
CORS_ALLOWED_ORIGINS = [
'exp://julyt-u-anonymous-8081.exp.direct',
'http://localhost:19006',
'http://192.168.153.13:8081',
'10.0..rest_of_the_ip',
]
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_WHITELIST = ('*')
ALLOWED_HOSTS = ['*']
I am launching the django server with:
python manage.py runserver 10.0..rest_of_the_ip:8000
I am launching the frontend with:
npx expo start --tunnel
When sending webrequest to the api endpoint, I get this in the frontend side:
E.g., ERROR API::loginUser->FAILED TO LOGIN USER: [TypeError: Network request failed]
Backend side does not receive anything.
This same setup works when I am using same wifi for both backend and frontend, for example when I am at a cafe:
python manage.py runserver local_IPv4:8000
npx expo start
And for the record, using npx expo start does not work when I am using this current wifi. The phone (expo go app) won't connect to the server, and thus it is not an option and I have to use the --tunnel flag.
I blurred the ip I am using normally, even though the IP starting with 10.0... is probably a local IPv4 address and nothing to worry about.
I tried to change the CORS settings from backend to allow the IP I am using, with no results.