fix: use wss:// for WebSocket connections when served over HTTPS#1583
fix: use wss:// for WebSocket connections when served over HTTPS#1583ianbmacdonald wants to merge 4 commits intolemonade-sdk:mainfrom
Conversation
|
@Geramy here it is with LePremierLaitier's suggested tweak |
|
@storm1er can you test this? |
Before
After
..lol I see to use this fix, you need to fake the port the frontend sees from /health .. so this fixes wss, but needs some iptables foo to get it working. thankfully linux is a network swiss army knife
Caddy Config And iptables foo |
why are we doing iptables? if you go to https://xxx.xxx.xxx.xxx/ it should hit the proxy and redirect to the real host/destination then the web app should automatically pull the browser URI without any acknowledgement of ports, so basically you just pull whatever is in the request uri and apply it to the wss side of things. Thats my understanding at least unless external_url is set then we use that. Does that make sense? |
WebSocket URLs were hardcoded to ws://, causing mixed-content errors when Lemonade is served behind an HTTPS reverse proxy. Derives the WebSocket protocol from the server base URL so wss:// is used automatically on HTTPS deployments. Fixes lemonade-sdk#472 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
afd7244 to
0b82025
Compare
This is because of the limitations on binding the proxy and lemonade to the same port on the same host .. if you wre testing with an external proxy, you could use a slightly different pattern and skip the iptables foo. Basically caddy and lemonade can not both bind to 9000 on the same interface, so we move one and use iptables. |
|
@Geramy any idea why CI is failing .. best I can tell some kind of crash |
so far it looks like a lot of things are "already downloaded" |
|
@ianbmacdonald I sent you a long-overdue invite to the project so that you can make branches on the main repo without forking, and can run your own CI automatically. |




Summary
ws://, causing mixed-content errors when Lemonade is served behind an HTTPS reverse proxygetWebSocketProtocol()helper that deriveswsorwssfrom the server base URL protocolThis is the narrow protocol-only fix. A broader
external_urlconfig for full reverse proxy support (including same-origin WebSocket routing) is available onfeat/external-url-configand described in #472 (comment).Test plan
http://— WebSocket connections should usews://(unchanged behavior)https://via reverse proxy — WebSocket connections should usewss://, no mixed-content errors in browser consoleFixes #472
🤖 Generated with Claude Code