I am hosting a reactjs project on port 3000 as front end and django project on port 8000 as backend on the same machine.
So when rendering, reactjs will get data by calling django APIs.
I (thought I) had correctly setup CORS headers in Django settings. Both http://localhost:3000/ and http://192.168.86.21:3000/ are working on my local machine. 192.168.86.21 is my LAN IP.
But when I access http://192.168.86.21:3000/ on another machine or tablet in my LAN. Only static files are rendered. I inspect Chrome network and it shows:
" Access to fetch at '..django_ip_port...' from origin '..my_ip_port..' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. "
It's really weird.