Fix cors on the index view (#24283)
This commit is contained in:
1 parent
ee71d2ca60
commit
014cc14b7e
2 files changed
+17
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user