Add django-cors-headers #4

Closed
opened 2020-10-23 05:04:27 -04:00 by pepper · 1 comment
Owner

A crucial part of allowing API access to external applciation is through CORS headers,

My API requests were returning a CORS error,

Request to add django-cors-headers to the requirements?

pip install django-cors-headers

Would provide the following additional settings in ./migratorapi/settings.py

INSTALLED_APPS = [
	...
    'corsheaders',
]
MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware', 
    ...
]

CORS_ORIGIN_ALLOW_ALL = True
#CORS_ORIGIN_WHITELIST = [
#    '*',
#    ]

This provides for API requests to succeed, from the frontend

In production, CORS_ORIGINS can be controlled more finely, and would prevent requests from unauthorized origins

peas and love

A crucial part of allowing API access to external applciation is through CORS headers, My API requests were returning a CORS error, Request to add django-cors-headers to the requirements? `pip install django-cors-headers` Would provide the following additional settings in ./migratorapi/settings.py ``` INSTALLED_APPS = [ ... 'corsheaders', ] MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', ... ] CORS_ORIGIN_ALLOW_ALL = True #CORS_ORIGIN_WHITELIST = [ # '*', # ] ``` This provides for API requests to succeed, from the frontend In production, CORS_ORIGINS can be controlled more finely, and would prevent requests from unauthorized origins peas and love
Owner

Added in commit 1a85c99752

Added in commit 1a85c99752
This repo is archived. You cannot comment on issues.
No Label
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: The_Bois/MigratorProject#4
No description provided.