Hi, I developed a simple mobile app on my local computer and am trying to access my django backend hosted on pythonanywhere.
I am getting the following errors:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.0.11:8105' is therefore not allowed access. The response had HTTP status code 401.
failed to load resource: the server responded with a status of 401 (Authorization Required)
defaultErrorLogger @ core.js:1449
After doing a little research I did the following:
pip install django-cors-headers
I added it to my install apps: INSTALLED_APPS = ( ... 'corsheaders', ... )
And to the top of my middleware classes:
MIDDLEWARE_CLASSES = ( 'corsheaders.middleware.CorsMiddleware',
And I put my remote access url into CORS_ORIGIN_WHITELIST and when that didn't work also tried CORS_ORIGIN_ALLOW_ALL but no matter what I do I still get the error.
Not sure if it's related to anything with pythonanywhere or not.