Make frontend service work

This commit is contained in:
2026-03-18 23:09:44 +00:00
parent f91dc97c38
commit a239600ffc
2 changed files with 17 additions and 8 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ import (
"github.com/BlackChaosNL/Orchestra/cmd/api/routes"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/cors"
"github.com/gofiber/fiber/v3/middleware/responsetime"
"github.com/kataras/golog"
)
@@ -17,8 +18,8 @@ const idleTimeout = 5 * time.Second
func StartAPIServer(wg *sync.WaitGroup) {
defer wg.Done()
app = fiber.New(fiber.Config{IdleTimeout: idleTimeout})
app.Use(golog.New())
app.Use(cors.New())
app.Use(responsetime.New())
g := app.Group("/api/v1/")
+15 -7
View File
@@ -1,11 +1,13 @@
package web
import (
"os"
"sync"
"time"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/cors"
"github.com/gofiber/fiber/v3/middleware/responsetime"
"github.com/gofiber/fiber/v3/middleware/static"
"github.com/kataras/golog"
)
@@ -18,17 +20,23 @@ func StartWebServer(wg *sync.WaitGroup) {
defer wg.Done()
app = fiber.New(fiber.Config{IdleTimeout: idleTimeout})
app.Use(golog.New())
app.Use(cors.New())
app.Use(responsetime.New())
app.Get("/", static.New("./ui/dist"), static.Config{
MaxAge: 0,
})
app.Get("/static/*", static.New("./ui/dist/static", static.Config{
MaxAge: 31536000, // 1 year
app.Get("/assets*", static.New("", static.Config{
MaxAge: 31536000, // 1 year
FS: os.DirFS("cmd/web/ui/dist/assets"),
Browse: true,
Compress: true,
}))
app.Get("/*", func(c fiber.Ctx) error {
return c.SendFile("cmd/web/ui/dist/index.html", fiber.SendFile{
MaxAge: 0, // Force fresh index.
Compress: true,
})
})
golog.Fatal(app.Listen(":9800"))
}