Skip to content

Commit

Permalink
bg(CORS): Add CORS to the project
Browse files Browse the repository at this point in the history
- Install django-cors-headers
- Add it in installed apps

[Starts #166378524]
  • Loading branch information
engjames committed May 31, 2019
1 parent 52a3120 commit 610b972
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions authors/cors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class CorsMiddleware(object):
def process_response(self, req, resp):
response["Access-Control-Allow-Origin"] = "*"
return response
7 changes: 7 additions & 0 deletions authors/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'),
Expand Down
7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 610b972

Please sign in to comment.