adamchainz / django-cors-headers

Django app for handling the server headers required for Cross-Origin Resource Sharing (CORS)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OPTIONS 200, POST 502

elcolie opened this issue · comments

Chrome: Version 74.0.3729.131 (Official Build) (64-bit)

200 with preflight OPTIONS
image

500 with POST
image
Preview, Response are blank

Setup:

Python3.7
requirements.txt

django-cors-headers==2.5.3
django==2.2.1
INSTALLED_APPS = [
    'corsheaders',
    ...
]
MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
CORS_ORIGIN_ALLOW_ALL = True

Question:

Where am I wrong?

The OPTIONS response comes from this middleware, but it's likely the 502 comes from your app somehow. If there was an error in this library, you would get a 500.

To debug this properly, you need the stack trace from Python rather than the browser responses, as they won't contain so much information.

Also, your site design looks a little odd. It's best practice to have either www or the apex domain (i.e. www.herr.reviews or herr.reviews) as a site, and have the other redirect to it. Users often forget to type "www" when visiting a domain.

Sorry I can't help you further