Fix Subpath behavior (#2818)

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2023-05-22 12:30:59 -07:00
committed by GitHub
parent 6e314a2fa5
commit 920fc7d937
2 changed files with 6 additions and 2 deletions

View File

@@ -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,

View File

@@ -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
}