mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-11 19:42:09 +08:00
Enforce wss for api key
This commit is contained in:
@@ -138,8 +138,9 @@ export default async function truenasProxyHandler(req, res, map) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let data;
|
let data;
|
||||||
const wsUrl = new URL(formatApiCall(widgets?.[widget.type]?.wsAPI, { ...widget }));
|
const wsUrl = new URL(formatApiCall(widgets[widget.type].wsAPI, { ...widget }));
|
||||||
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
const useSecure = wsUrl.protocol === "https:" || Boolean(widget.key); // API key requires secure connection
|
||||||
|
wsUrl.protocol = useSecure ? "wss:" : "ws:";
|
||||||
logger.info("Connecting to TrueNAS websocket at %s", wsUrl);
|
logger.info("Connecting to TrueNAS websocket at %s", wsUrl);
|
||||||
const ws = new WebSocket(wsUrl, { rejectUnauthorized: false });
|
const ws = new WebSocket(wsUrl, { rejectUnauthorized: false });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user