I am batman
This commit is contained in:
30
internal/server/server.go
Normal file
30
internal/server/server.go
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user