From 8c80b20cf421ada026f6b5f5a4b0b824c99b4666 Mon Sep 17 00:00:00 2001 From: mist Date: Fri, 23 Apr 2021 09:32:59 +0200 Subject: [PATCH] cors --- Pipfile | 1 + Pipfile.lock | 10 +++++++++- pakajo/settings.py | 9 ++++----- requirements.txt | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Pipfile b/Pipfile index 9fea633..7157a66 100644 --- a/Pipfile +++ b/Pipfile @@ -10,6 +10,7 @@ django = "*" djangorestframework = "*" markdown = "*" pillow = "*" +django-cors-headers = "*" [requires] python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock index 398b6e7..7659127 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "1cacd6133aec887ab1622c274f09c244ceab1ccfba1de3b5e30b142e5d0d50d4" + "sha256": "c79ef1feabc309b7e4c8159095e887b74e4c0c5c5fb87883b28909f573ab4d0a" }, "pipfile-spec": 6, "requires": { @@ -32,6 +32,14 @@ "index": "pypi", "version": "==3.2" }, + "django-cors-headers": { + "hashes": [ + "sha256:1ac2b1213de75a251e2ba04448da15f99bcfcbe164288ae6b5ff929dc49b372f", + "sha256:96069c4aaacace786a34ee7894ff680780ec2644e4268b31181044410fecd12e" + ], + "index": "pypi", + "version": "==3.7.0" + }, "djangorestframework": { "hashes": [ "sha256:6d1d59f623a5ad0509fe0d6bfe93cbdfe17b8116ebc8eda86d45f6e16e819aaf", diff --git a/pakajo/settings.py b/pakajo/settings.py index c7b97bf..22e516d 100644 --- a/pakajo/settings.py +++ b/pakajo/settings.py @@ -40,6 +40,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'corsheaders', 'rest_framework', 'rest_framework.authtoken', 'pak', @@ -48,6 +49,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -120,16 +122,13 @@ USE_L10N = True USE_TZ = True -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ - -STATIC_URL = '/static/' - # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +CORS_ORIGIN_ALLOW_ALL = True +CORS_ALLOW_CREDENTIALS = True REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ diff --git a/requirements.txt b/requirements.txt index cb70fd3..f8691cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ -i https://pypi.org/simple asgiref==3.3.4; python_version >= '3.6' +django-cors-headers==3.7.0 django==3.2 djangorestframework==3.12.4 markdown==3.3.4