Fix proxy for websockets

This commit is contained in:
Bartosz Wieczorek 2025-06-25 19:33:42 +02:00
parent c1806bc911
commit b629f2d7e1

View File

@ -79,8 +79,6 @@ class WebSocket {
info.protocols = protocols; info.protocols = protocols;
info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
context = lws_create_context(&info);
if(cfg.proxyEnabled && (cfg.proxyType == "http" || cfg.proxyType == "https")) { if(cfg.proxyEnabled && (cfg.proxyType == "http" || cfg.proxyType == "https")) {
assert(cfg.proxyType.has_value()); assert(cfg.proxyType.has_value());
assert(cfg.proxyHost.has_value()); assert(cfg.proxyHost.has_value());
@ -101,6 +99,8 @@ class WebSocket {
info.http_proxy_port = config.proxyPort.value_or(8080); info.http_proxy_port = config.proxyPort.value_or(8080);
} }
context = lws_create_context(&info);
const std::string_view prefix = "https://"; const std::string_view prefix = "https://";
if(urlv.substr(0, prefix.size()) == prefix) if(urlv.substr(0, prefix.size()) == prefix)
urlv.remove_prefix(prefix.size()); urlv.remove_prefix(prefix.size());