Make frontend service work
This commit is contained in:
+2
-1
@@ -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
@@ -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"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user