From d7fb2e626c05638f1373e6907bb65e71cd1d3bd0 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 4 Jun 2019 10:28:48 +0800 Subject: [PATCH] add corsheaders --- BookingService/settings.py | 4 ++++ Pipfile | 1 + Pipfile.lock | 22 +++++++++++++++------- deploy/deploy.sh | 2 ++ requirements.txt | 5 +++-- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/BookingService/settings.py b/BookingService/settings.py index 092ed39..9fa6b4a 100644 --- a/BookingService/settings.py +++ b/BookingService/settings.py @@ -40,6 +40,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'rest_framework', 'django_filters', + 'corsheaders', 'user', 'booking', 'utils', @@ -54,6 +55,7 @@ MIDDLEWARE = [ # 'django.middleware.cache.UpdateCacheMiddleware', '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', @@ -215,3 +217,5 @@ if DEBUG: # DEBUG_TOOLBAR_PATCH_SETTINGS = False INTERNAL_IPS = ('127.0.0.1', 'localhost') +# CORS +CORS_ORIGIN_ALLOW_ALL = True diff --git a/Pipfile b/Pipfile index ed9096d..0796488 100644 --- a/Pipfile +++ b/Pipfile @@ -16,6 +16,7 @@ eventlet = "*" psycopg2 = "*" python-memcached = "*" qrcode = {extras = ["pil"],version = "*"} +django-cors-headers = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index 8bda3fe..0558dd6 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "1e97ca750e0514dd32253773df5c99acd2df1c3ed92d5b615c79a581ca6b9329" + "sha256": "df8a98b304731b91b12068a2019a11d77dc94a253426cb3c2fc2199434266f93" }, "pipfile-spec": 6, "requires": { @@ -18,10 +18,10 @@ "default": { "amqp": { "hashes": [ - "sha256:043beb485774ca69718a35602089e524f87168268f0d1ae115f28b88d27f92d7", - "sha256:35a3b5006ca00b21aaeec8ceea07130f07b902dd61bfe42815039835f962f5f1" + "sha256:aa4409446139676943a2eaa27d5f58caf750f4ca5a89f888c452afd86be6a67d", + "sha256:cbb6f87d53cac612a594f982b717cc1c54c6a1e17943a0a0d32dc6cc9e2120c8" ], - "version": "==2.4.2" + "version": "==2.5.0" }, "babel": { "hashes": [ @@ -60,6 +60,14 @@ "index": "pypi", "version": "==2.2.1" }, + "django-cors-headers": { + "hashes": [ + "sha256:5b80bf0f8d7fc6e2bcb4f40781d5ff3661961bbf1982e52daec77241dea3b890", + "sha256:ebf3e2cf25aa6993b959a8e6a87828ebb3c8fe5bc3ec4a2d6e65f3b8d9b4212c" + ], + "index": "pypi", + "version": "==3.0.2" + }, "django-filter": { "hashes": [ "sha256:3dafb7d2810790498895c22a1f31b2375795910680ac9c1432821cbedb1e176d", @@ -124,10 +132,10 @@ }, "kombu": { "hashes": [ - "sha256:389ba09e03b15b55b1a7371a441c894fd8121d174f5583bbbca032b9ea8c9edd", - "sha256:7b92303af381ef02fad6899fd5f5a9a96031d781356cd8e505fa54ae5ddee181" + "sha256:14997e6d76d36f2b296f57e37fd1d388e4e0159edea8368a8c6f4620a355a722", + "sha256:27345bb569eb6bb583bca27dfc0ef181ca6c59c40c6e203cecaa0aeca84360be" ], - "version": "==4.5.0" + "version": "==4.6.0" }, "monotonic": { "hashes": [ diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 7451ccd..83408b8 100644 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -8,6 +8,8 @@ git pull echo echo 2/5 Install python dependencies and migrate +docker exec ${CONTAINER_NAME}_celery /bin/sh -c "cd /project \ + && pip install -r requirements.txt" docker exec $CONTAINER_NAME /bin/sh -c "cd /project \ && pip install -r requirements.txt \ && python manage.py migrate" diff --git a/requirements.txt b/requirements.txt index d9bd1bf..0724208 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,11 @@ -amqp==2.4.2 +amqp==2.5.0 anyjson==0.3.3 Babel==2.7.0 billiard==3.6.0.0 celery==4.3.0 colorama==0.4.1 Django==2.2.1 +django-cors-headers==3.0.2 django-debug-toolbar==1.11 django-filter==2.1.0 djangorestframework==3.9.4 @@ -12,7 +13,7 @@ dnspython==1.16.0 eventlet==0.25.0 flower==0.9.3 greenlet==0.4.15 -kombu==4.5.0 +kombu==4.6.0 monotonic==1.5 Pillow==6.0.0 psycopg2==2.8.2