I have a dummy FastAPI app, which works fine on my mac, but doesn't when I host it on a VM using docker. The login page sends an ajax request to /login
endpoint, which I have written as http://localhost:8000/login
, which works on my mac, but when I access the app on VM, by typing its ip address in my browser, I get this error:
Access to XMLHttpRequest at 'http://localhost:8000/login' from origin 'http://[the IP address of my VM here]' has been blocked by CORS policy.
How can I resolve this?