Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force Content-Type for frontend #1786

Merged
merged 1 commit into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions custom_components/hacs/operational/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ async def async_startup_wrapper_for_yaml():
startup_result = False
if not startup_result:
hacs.system.disabled = True
hacs.hass.components.frontend.async_remove_panel(
hacs.configuration.sidepanel_title.lower()
.replace(" ", "_")
.replace("-", "_")
)
hacs.log.info("Could not setup HACS, trying again in 15 min")
async_call_later(hacs.hass, 900, async_startup_wrapper_for_yaml)
return
Expand Down
19 changes: 8 additions & 11 deletions custom_components/hacs/operational/setup_actions/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,18 @@ async def async_setup_frontend():

# Add to sidepanel
if "hacs" not in hacs.hass.data.get("frontend_panels", {}):
custom_panel_config = {
"name": "hacs-frontend",
"embed_iframe": True,
"trust_external": False,
"js_url": "/hacsfiles/frontend/entrypoint.js",
}

config = {}
config["_panel_custom"] = custom_panel_config

hacs.hass.components.frontend.async_register_built_in_panel(
component_name="custom",
sidebar_title=hacs.configuration.sidepanel_title,
sidebar_icon=hacs.configuration.sidepanel_icon,
frontend_url_path="hacs",
config=config,
config={
"_panel_custom": {
"name": "hacs-frontend",
"embed_iframe": True,
"trust_external": False,
"js_url": "/hacsfiles/frontend/entrypoint.js",
}
},
require_admin=True,
)
2 changes: 1 addition & 1 deletion custom_components/hacs/webresponses/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ async def async_serve_frontend(requested_file):
return web.Response(status=404)

response = web.FileResponse(servefile)
response.headers["Content-Type"] = "application/javascript"

if dev:
response.headers["Content-Type"] = "application/javascript"
response.headers["Cache-Control"] = "no-store, max-age=0"
response.headers["Pragma"] = "no-store"
return response