Skip to content

Commit a0f7de3

Browse files
committed
fix: static file serving 502 and caching issues
1 parent 1f1fb66 commit a0f7de3

4 files changed

Lines changed: 18 additions & 16 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@
123123
"--watch-ports",
124124
"-p",
125125
"9190",
126-
"--idle",
127-
"--jwks-server",
128-
"https://auth.druid.gg/.well_known/jwks.json"
126+
"--idle"
129127
],
130128
},
131129
{

cmd/server/web/server.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package web
33
import (
44
"errors"
55
"fmt"
6+
"net/http"
67

7-
"github.com/gofiber/adaptor/v2"
88
"github.com/gofiber/contrib/websocket"
99
"github.com/gofiber/fiber/v2"
10+
"github.com/gofiber/fiber/v2/middleware/adaptor"
1011
"github.com/gofiber/fiber/v2/middleware/cors"
12+
"github.com/gofiber/fiber/v2/middleware/filesystem"
1113
jwtware "github.com/gofiber/jwt/v3"
1214
"github.com/highcard-dev/daemon/cmd/server/web/middlewares"
1315

@@ -198,10 +200,16 @@ func (s *Server) SetAPI(app *fiber.App) *fiber.App {
198200
apiRoutes.Get("/ports", s.portHandler.GetPorts).Name("ports.list")
199201

200202
publicUiRoutes.Get("/public/index", s.uiHandler.PublicIndex).Name("ui.public_index")
201-
publicUiRoutes.Static("/public", s.scrollPath+"/public").Name("ui.public")
203+
publicUiRoutes.Use("/public", filesystem.New(filesystem.Config{
204+
Root: http.Dir(s.scrollPath + "/public"),
205+
Browse: false,
206+
}))
202207

203208
privateUiRoutes.Get("/private/index", s.uiHandler.PrivateIndex).Name("ui.private_index")
204-
privateUiRoutes.Static("/private", s.scrollPath+"/private").Name("ui.private")
209+
privateUiRoutes.Use("/private", filesystem.New(filesystem.Config{
210+
Root: http.Dir(s.scrollPath + "/private"),
211+
Browse: false,
212+
}))
205213

206214
if s.annotationHandler != nil {
207215
app.Get("/annotations", s.annotationHandler.Annotations).Name("annotations.list")

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ toolchain go1.24.7
77
require (
88
github.com/Masterminds/semver/v3 v3.2.1
99
github.com/Masterminds/sprig v2.22.0+incompatible
10-
github.com/gofiber/adaptor/v2 v2.2.1
11-
github.com/gofiber/contrib/websocket v1.3.2
12-
github.com/gofiber/fiber/v2 v2.52.5
10+
github.com/gofiber/contrib/websocket v1.3.4
11+
github.com/gofiber/fiber/v2 v2.52.9
1312
github.com/hashicorp/go-plugin v1.6.1
1413
github.com/opencontainers/image-spec v1.1.0
1514
github.com/prometheus/client_golang v1.19.1
@@ -102,7 +101,6 @@ require (
102101
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
103102
github.com/sirupsen/logrus v1.9.3 // indirect
104103
github.com/sourcegraph/conc v0.3.0 // indirect
105-
github.com/stretchr/testify v1.10.0 // indirect
106104
go.uber.org/atomic v1.9.0 // indirect
107105
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
108106
)

go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogB
6262
github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
6363
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
6464
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
65-
github.com/gofiber/adaptor/v2 v2.2.1 h1:givE7iViQWlsTR4Jh7tB4iXzrlKBgiraB/yTdHs9Lv4=
66-
github.com/gofiber/adaptor/v2 v2.2.1/go.mod h1:AhR16dEqs25W2FY/l8gSj1b51Azg5dtPDmm+pruNOrc=
67-
github.com/gofiber/contrib/websocket v1.3.2 h1:AUq5PYeKwK50s0nQrnluuINYeep1c4nRCJ0NWsV3cvg=
68-
github.com/gofiber/contrib/websocket v1.3.2/go.mod h1:07u6QGMsvX+sx7iGNCl5xhzuUVArWwLQ3tBIH24i+S8=
65+
github.com/gofiber/contrib/websocket v1.3.4 h1:tWeBdbJ8q0WFQXariLN4dBIbGH9KBU75s0s7YXplOSg=
66+
github.com/gofiber/contrib/websocket v1.3.4/go.mod h1:kTFBPC6YENCnKfKx0BoOFjgXxdz7E85/STdkmZPEmPs=
6967
github.com/gofiber/fiber/v2 v2.45.0/go.mod h1:DNl0/c37WLe0g92U6lx1VMQuxGUQY5V7EIaVoEsUffc=
70-
github.com/gofiber/fiber/v2 v2.52.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo=
71-
github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
68+
github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw=
69+
github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
7270
github.com/gofiber/jwt/v3 v3.3.10 h1:0bpWtFKaGepjwYTU4efHfy0o+matSqZwTxGMo5a+uuc=
7371
github.com/gofiber/jwt/v3 v3.3.10/go.mod h1:GJorFVaDyfMPSK9RB8RG4NQ3s1oXKTmYaoL/ny08O1A=
7472
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=

0 commit comments

Comments
 (0)