31 lines
670 B
Go
31 lines
670 B
Go
package server
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
|
)
|
|
|
|
type FiberServer struct {
|
|
*fiber.App
|
|
}
|
|
|
|
func New() *FiberServer {
|
|
server := &FiberServer{
|
|
App: fiber.New(fiber.Config{
|
|
ServerHeader: "OpsMastery.v5",
|
|
AppName: "OpsMastery.v5",
|
|
}),
|
|
}
|
|
|
|
// Correct CORS origin to allow your frontend domain
|
|
server.App.Use(cors.New(cors.Config{
|
|
AllowOrigins: "http://localhost:3000",
|
|
AllowMethods: "GET,POST,PUT,DELETE,OPTIONS,PATCH",
|
|
AllowHeaders: "Accept,Authorization,Content-Type",
|
|
AllowCredentials: true, // allow credentials for cookies/auth
|
|
MaxAge: 300,
|
|
}))
|
|
|
|
return server
|
|
}
|