Change static assets and websocket interface to /sshwifty/assets and /sshwifty/socket. This should allow user to map Sshwifty to a subdirectory behind a reverse proxy
This commit is contained in:
@@ -34,6 +34,11 @@ var (
|
||||
http.StatusNotFound, "Page not found")
|
||||
)
|
||||
|
||||
const (
|
||||
assetsURLPrefix = "/sshwifty/assets/"
|
||||
assetsURLPrefixLen = len(assetsURLPrefix)
|
||||
)
|
||||
|
||||
// handler is the main service dispatcher
|
||||
type handler struct {
|
||||
hostNameChecker string
|
||||
@@ -73,14 +78,39 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
case "/":
|
||||
err = serveController(h.homeCtl, w, r, clientLogger)
|
||||
|
||||
case "/socket":
|
||||
case "/sshwifty/socket":
|
||||
err = serveController(h.socketCtl, w, r, clientLogger)
|
||||
|
||||
case "/robots.txt":
|
||||
err = serveStaticCacheData(
|
||||
"robots.txt",
|
||||
staticFileExt(".txt"),
|
||||
w,
|
||||
r,
|
||||
clientLogger)
|
||||
|
||||
case "/favicon.ico":
|
||||
err = serveStaticCacheData(
|
||||
"favicon.ico",
|
||||
staticFileExt(".ico"),
|
||||
w,
|
||||
r,
|
||||
clientLogger)
|
||||
|
||||
case "/manifest.json":
|
||||
err = serveStaticCacheData(
|
||||
"manifest.json",
|
||||
staticFileExt(".json"),
|
||||
w,
|
||||
r,
|
||||
clientLogger)
|
||||
|
||||
default:
|
||||
if len(r.URL.Path) > 0 && strings.ToUpper(r.Method) == "GET" {
|
||||
if strings.HasPrefix(r.URL.Path, assetsURLPrefix) &&
|
||||
strings.ToUpper(r.Method) == "GET" {
|
||||
err = serveStaticCacheData(
|
||||
r.URL.Path[1:],
|
||||
staticFileExt(r.URL.Path[1:]),
|
||||
r.URL.Path[assetsURLPrefixLen:],
|
||||
staticFileExt(r.URL.Path[assetsURLPrefixLen:]),
|
||||
w,
|
||||
r,
|
||||
clientLogger)
|
||||
|
||||
@@ -65,6 +65,8 @@ const mainTemplate = `
|
||||
<loading v-else :error="loadErr"></loading>
|
||||
`.trim();
|
||||
|
||||
const socksInterface = "/sshwifty/socket";
|
||||
|
||||
function startApp(rootEl) {
|
||||
const pageTitle = document.title;
|
||||
|
||||
@@ -149,7 +151,7 @@ function startApp(rootEl) {
|
||||
r = "ws://";
|
||||
}
|
||||
|
||||
r += location.host + "/socket";
|
||||
r += location.host + socksInterface;
|
||||
|
||||
return r;
|
||||
},
|
||||
@@ -249,7 +251,7 @@ function startApp(rootEl) {
|
||||
? null
|
||||
: await this.getSocketAuthKey(privateKey, this.key);
|
||||
|
||||
let h = await xhr.head("/socket", {
|
||||
let h = await xhr.head(socksInterface, {
|
||||
"X-Key": authKey ? btoa(String.fromCharCode.apply(null, authKey)) : ""
|
||||
});
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ module.exports = {
|
||||
devtool:
|
||||
process.env.NODE_ENV === "development" ? "inline-source-map" : "source-map",
|
||||
output: {
|
||||
publicPath: "/",
|
||||
publicPath: "/sshwifty/assets/",
|
||||
path: path.join(__dirname, ".tmp", "dist"),
|
||||
filename: process.env.NODE_ENV === "development" ? "[id].js" : "[hash].js"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user