Fix cors on the index view (#24283)

This commit is contained in:
Paulus Schoutsen committed 2019-06-03 12:41:35 -07:00
1 parent ee71d2ca60
commit 014cc14b7e
2 files changed
+17

No files matched your search

+5
View File
@@ -1,4 +1,5 @@
"""Provide CORS support for the HTTP component."""
from aiohttp.web_urldispatcher import Resource, ResourceRoute
from aiohttp.hdrs import ACCEPT, CONTENT_TYPE, ORIGIN, AUTHORIZATION
from homeassistant.const import (
@@ -8,6 +9,7 @@ from homeassistant.core import callback
ALLOWED_CORS_HEADERS = [
ORIGIN, ACCEPT, HTTP_HEADER_X_REQUESTED_WITH, CONTENT_TYPE,
HTTP_HEADER_HA_AUTH, AUTHORIZATION]
VALID_CORS_TYPES = (Resource, ResourceRoute)
@callback
@@ -31,6 +33,9 @@ def setup_cors(app, origins):
else:
path = route
if not isinstance(path, VALID_CORS_TYPES):
return
path = path.canonical
if path in cors_added: