From 304f706dd61511e4a49ed40b60e108d96837bcab Mon Sep 17 00:00:00 2001 From: nikurasu Date: Sun, 26 Nov 2023 21:46:50 +0100 Subject: [PATCH] FEATURE: Add Cors --- src/config/cors.go | 9 +++++++++ src/main.go | 1 + 2 files changed, 10 insertions(+) create mode 100644 src/config/cors.go diff --git a/src/config/cors.go b/src/config/cors.go new file mode 100644 index 0000000..0242b24 --- /dev/null +++ b/src/config/cors.go @@ -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", + })) +} diff --git a/src/main.go b/src/main.go index 83b9986..eeaabe1 100644 --- a/src/main.go +++ b/src/main.go @@ -18,6 +18,7 @@ func main() { config.SetupValidator() config.SetupMiddlewares() config.SetupFiber(viewFS) + config.SetupCors() if config.Env.Debug { config.App.Use(cors.New(cors.Config{