Skip to content

Commit

Permalink
add cors headers - issue #62
Browse files Browse the repository at this point in the history
  • Loading branch information
drkane committed Feb 11, 2020
1 parent e245b2b commit 71efb3f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion findthatcharity/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from starlette.applications import Starlette
from starlette.routing import Route, Mount
from starlette.staticfiles import StaticFiles
from starlette.middleware import Middleware
from starlette.middleware.cors import CORSMiddleware

from .queries import search_query
from .db import es, fetch_all_sources
Expand Down Expand Up @@ -77,5 +79,13 @@ def search_return(query, request):
Mount('/orgid', routes=orgid.routes, name='orgid'),
Mount('/adddata', csvdata.app),
]
middleware = [
Middleware(
CORSMiddleware,
allow_origins=['*'],
allow_methods=['GET', 'POST', 'OPTIONS'],
allow_headers=['Origin', 'Accept', 'Content-Type', 'X-Requested-With', 'X-CSRF-Token'],
)
]

app = Starlette(routes=routes, debug=settings.DEBUG)
app = Starlette(routes=routes, debug=settings.DEBUG, middleware=middleware)

0 comments on commit 71efb3f

Please sign in to comment.