Rename internal asset path to /_gw/ to avoid collision with user apps

This commit is contained in:
Jose Luis Montañes Ojados
2026-01-27 03:16:08 +01:00
parent 8e473a5bae
commit 736922ca77
2 changed files with 6 additions and 7 deletions

View File

@@ -76,9 +76,8 @@ func (tm *TunnelManager) FindSlugByConn(conn *gossh.ServerConn) (string, bool) {
// HTTP Proxy to forward requests to the SSH tunnel
func startHttpProxy(port string) {
log.Printf("Starting HTTP Proxy on %s", port)
// Serve static files for 404 page
http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("./cmd/server/static/assets"))))
// Serve static files for 404 page (namespaced to avoid collision with user apps)
http.Handle("/_gw/", http.StripPrefix("/_gw/", http.FileServer(http.Dir("./cmd/server/static/assets"))))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Extract subdomain to identify the tunnel
@@ -126,7 +125,7 @@ func startHttpProxy(port string) {
// But typically `gliderlabs/ssh` is for allowing the server to be a jump host.
// We want to be an HTTP Gateway.
// 1. Hijack the connection to handle bidirectional traffic (WebSockets)
// 1. Hijack the connection to handle bidirectional traffic (WebSockets)
hijacker, ok := w.(http.Hijacker)
if !ok {
http.Error(w, "Hijacking not supported", http.StatusInternalServerError)

View File

@@ -16,11 +16,11 @@
<link
rel="stylesheet"
id="a3a3_lazy_load-css"
href="./assets/a3_lazy_load.min.css"
href="/_gw/a3_lazy_load.min.css"
type="text/css"
media="all"
/>
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="/_gw/style.css">
</head>
<body>
<section class="error_404">
@@ -49,7 +49,7 @@
<!-- Astronaut -->
<div class="error_404_astro">
<object data="assets/astro.svg"></object>
<object data="/_gw/astro.svg"></object>
</div>
</div>