FEATURE: Add Cors

This commit is contained in:
nikurasu 2023-11-26 21:46:50 +01:00
parent 407deace22
commit 304f706dd6
Signed by: Nikurasu
GPG key ID: 9E7F14C03EF1F271
2 changed files with 10 additions and 0 deletions

9
src/config/cors.go Normal file
View file

@ -0,0 +1,9 @@
package config
import "github.com/gofiber/fiber/v2/middleware/cors"
func SetupCors() {
App.Use(cors.New(cors.Config{
AllowOrigins: "http://localhost:5173",
}))
}

View file

@ -18,6 +18,7 @@ func main() {
config.SetupValidator() config.SetupValidator()
config.SetupMiddlewares() config.SetupMiddlewares()
config.SetupFiber(viewFS) config.SetupFiber(viewFS)
config.SetupCors()
if config.Env.Debug { if config.Env.Debug {
config.App.Use(cors.New(cors.Config{ config.App.Use(cors.New(cors.Config{