Hello developers,

I am using Django 1.9 with python 3.5. On the frontend we are using 
Angularjs and we are trying to access the API. While trying to access POST, 
the API hits with OPTIONS method and the data does not comes up. I thought 
to use django-cors-headers and used all the settings as specified in the 
django-cors-headers documentation, and ultimately came to know the 
django-cors-headers supports only Django 1.8 for now. After that I am 
unsure what to use to avoid OPTIONS preflight issue. 

Here is my staging.py (settings)


from .base import *

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': get_secret('DATABASE_NAME'),
        'USER': get_secret('DATABASE_USER'),
        'PASSWORD': get_secret('DATABASE_PASSWORD'),
        'HOST': 'XXXX.XXXXX.com',
        'PORT': '5432',  # you can change this like: 
DATABASES['default']['PORT'] = 'some_other_port'
    }
}
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = get_secret("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = get_secret("EMAIL_HOST_PASSWORD")
EMAIL_PORT = 587
EMAIL_USE_TLS = True

SERVER_EMAIL = "test...@abcd.com"
ADMINS = (
    ('admin','ad...@abcd.com')
)

SITE_ADDRESS = 'http://api.admin.com'

MEDIA_ROOT = str(BASE_DIR / 'media')

STATIC_ROOT = str(BASE_DIR / 'staticfiles')

STATIC_URL = '/static/'

MEDIA_URL = '/media/'

LOCAL_SMS_RECIPIENT = get_secret('LOCAL_SMS_RECIPIENT')

LOCAL_EMAIL_RECIPIENTS = get_secret('LOCAL_EMAIL_RECIPIENTS')

BROKER_URL = 'redis://localhost:6379'  # TODO: on production, this has to be on 
RabbitMQ
CELERY_RESULT_BACKEND = 'redis://localhost:6379'

TEST_FACEBOOK_ACCESS_TOKEN = get_secret("TEST_FACEBOOK_ACCESS_TOKEN")
TEST_GOOGLE_ACCESS_TOKEN = get_secret("TEST_GOOGLE_ACCESS_TOKEN")


# CORS_ORIGIN_ALLOW_ALL = True
#
# CORS_ALLOW_HEADERS = (
#         'x-requested-with',
#         'content-type',
#         'accept',
#         'origin',
#         'authorization',
#         'x-csrftoken'
#     )
#
# CORS_ALLOW_METHODS = (
#         'GET',
#         'POST',
#         'PUT',
#         'PATCH',
#         'DELETE',
#         'OPTIONS'
#     )

CORS_ALLOW_HEADERS = (
    'content-type',
)

CORS_ALLOW_METHODS = (
         'GET',
         'POST',
         'PUT',
         'PATCH',
         'DELETE'
     )


EXCEPTION_MASKING = False


could anyone please let me know how to overcome the OPTIONS preflight 
error. I am stucked in this issue.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1e942b30-c0ec-4cdc-880b-bf37f2d2a37a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to