Fix WebSocket 403 in dev mode by allowing localhost origins
Deploy with Docker Compose / deploy (push) Has been cancelled

The CheckOrigin function only accepted the production domain, rejecting
localhost connections in dev. Also removed redundant error response after
a failed upgrade since the upgrader already writes its own HTTP response.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
2026-03-25 16:59:13 +00:00
co-authored by Claude Opus 4.6
parent d3d3269d49
commit 29350af2e0
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -26,7 +26,9 @@ var Upgrader = websocket.Upgrader{
}
origin = strings.TrimPrefix(origin, "https://")
origin = strings.TrimPrefix(origin, "http://")
return origin == allowedDomain || origin == "www."+allowedDomain
// Strip port for localhost comparisons (e.g. "localhost:80")
host := strings.Split(origin, ":")[0]
return origin == allowedDomain || origin == "www."+allowedDomain || host == "localhost"
},
}