--cors Access-Control-Allow-Headers: Authorization

Refs #1467, refs https://github.com/simonw/datasette-auth-tokens/issues/4
This commit is contained in:
Simon Willison 2021-10-14 12:03:28 -07:00
commit 8584993529
7 changed files with 20 additions and 11 deletions

View file

@ -1,7 +1,7 @@
import hashlib
import json
from datasette.utils import check_visibility, CustomJSONEncoder
from datasette.utils import add_cors_headers, check_visibility, CustomJSONEncoder
from datasette.utils.asgi import Response
from datasette.version import __version__
@ -129,7 +129,7 @@ class IndexView(BaseView):
if as_format:
headers = {}
if self.ds.cors:
headers["Access-Control-Allow-Origin"] = "*"
add_cors_headers(headers)
return Response(
json.dumps({db["name"]: db for db in databases}, cls=CustomJSONEncoder),
content_type="application/json; charset=utf-8",