Skip to content

Commit

Permalink
Fix Subpath behavior (#2818)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
  • Loading branch information
dvaldivia committed May 22, 2023
1 parent 6e314a2 commit 920fc7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions portal-ui/src/api/index.ts
@@ -1,6 +1,7 @@
import { Api, HttpResponse, Error, FullRequestParams } from "./consoleApi";

export let api = new Api();
api.baseUrl = `${new URL(document.baseURI).pathname}api/v1`;
const internalRequestFunc = api.request;
api.request = async <T = any, E = any>({
body,
Expand Down
7 changes: 5 additions & 2 deletions restapi/ws_handle.go
Expand Up @@ -148,8 +148,11 @@ func serveWS(w http.ResponseWriter, req *http.Request) {
errorsApi.ServeError(w, req, errorsApi.New(http.StatusUnauthorized, err.Error()))
return
}
// Development mode validation
if getConsoleDevMode() {

// If we are using a subpath we are most likely behind a reverse proxy so we most likely
// can't validate the proper Origin since we don't know the source domain, so we are going
// to allow the connection to be upgraded in this case.
if getSubPath() != "/" || getConsoleDevMode() {
upgrader.CheckOrigin = func(r *http.Request) bool {
return true
}
Expand Down

0 comments on commit 920fc7d

Please sign in to comment.