Skip to content

Commit 920fc7d

Browse files
authored
Fix Subpath behavior (#2818)
Signed-off-by: Daniel Valdivia <[email protected]>
1 parent 6e314a2 commit 920fc7d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

portal-ui/src/api/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Api, HttpResponse, Error, FullRequestParams } from "./consoleApi";
22

33
export let api = new Api();
4+
api.baseUrl = `${new URL(document.baseURI).pathname}api/v1`;
45
const internalRequestFunc = api.request;
56
api.request = async <T = any, E = any>({
67
body,

restapi/ws_handle.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ func serveWS(w http.ResponseWriter, req *http.Request) {
148148
errorsApi.ServeError(w, req, errorsApi.New(http.StatusUnauthorized, err.Error()))
149149
return
150150
}
151-
// Development mode validation
152-
if getConsoleDevMode() {
151+
152+
// If we are using a subpath we are most likely behind a reverse proxy so we most likely
153+
// can't validate the proper Origin since we don't know the source domain, so we are going
154+
// to allow the connection to be upgraded in this case.
155+
if getSubPath() != "/" || getConsoleDevMode() {
153156
upgrader.CheckOrigin = func(r *http.Request) bool {
154157
return true
155158
}

0 commit comments

Comments
 (0)