diff --git a/authors/cors.py b/authors/cors.py new file mode 100644 index 0000000..4a08d69 --- /dev/null +++ b/authors/cors.py @@ -0,0 +1,4 @@ +class CorsMiddleware(object): + def process_response(self, req, resp): + response["Access-Control-Allow-Origin"] = "*" + return response \ No newline at end of file diff --git a/authors/settings.py b/authors/settings.py index c33cd87..ed705b5 100644 --- a/authors/settings.py +++ b/authors/settings.py @@ -75,6 +75,7 @@ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'simple_history.middleware.HistoryRequestMiddleware', + 'django.middleware.common.BrokenLinkEmailsMiddleware', ] ROOT_URLCONF = 'authors.urls' @@ -216,7 +217,13 @@ TWITTER_CONSUMER_KEY = os.getenv('TWITTER_CONSUMER_KEY') TWITTER_CONSUMER_SECRET = os.getenv('TWITTER_CONSUMER_SECRET') +CORS_ORIGIN_ALLOW_ALL = True +CORS_ORIGIN_WHITELIST = [ + 'http://localhost:3000', + 'http://localhost:8000', + 'http://localhost:8080', +] #instantiate pusher with keys got from the .env file pusher = Pusher( app_id=os.getenv('APP_ID'), diff --git a/requirements.txt b/requirements.txt index 3ad4139..91d66a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,13 +12,17 @@ certifi==2019.3.9 cffi==1.12.3 channels==2.1.2 chardet==3.0.4 +constantly==15.1.0 coreapi==2.3.3 coreschema==0.0.4 coverage==4.5.3 coveralls==1.7.0 +cryptography==2.7 +daphne==2.3.0 defusedxml==0.6.0 dj-database-url==0.5.0 Django==2.1 +django-cors-headers==3.0.2 django-cors-middleware==1.3.1 django-extensions==2.1.6 django-filter==2.1.0 @@ -38,13 +42,12 @@ google-auth==1.6.3 gunicorn==19.9.0 hyperlink==19.0.0 idna==2.8 +incremental==17.5.0 inflection==0.3.1 itypes==1.1.0 Jinja2==2.10.1 linecache2==1.0.0 MarkupSafe==1.1.1 -incremental==17.5.0 -linecache2==1.0.0 mccabe==0.6.1 more-itertools==7.0.0 msgpack-python==0.5.6