From b7a81889a321a01d09afdf9e6c56297e565001f9 Mon Sep 17 00:00:00 2001 From: William P Date: Sun, 25 May 2025 13:43:52 -0400 Subject: [PATCH] paramaterize CORS --- api/api.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/api.go b/api/api.go index 386fa84..6ca5ac5 100644 --- a/api/api.go +++ b/api/api.go @@ -5,6 +5,8 @@ import ( "fmt" "log/slog" "net/http" + "os" + "strings" "git.dubyatp.xyz/chat-api-server/db" "github.com/go-chi/chi/v5" @@ -36,7 +38,7 @@ func Start() { r := chi.NewRouter() r.Use(cors.Handler(cors.Options{ - AllowedOrigins: []string{"http://localhost:5000"}, + AllowedOrigins: strings.Split(os.Getenv("ALLOWED_ORIGINS"), ","), AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"}, ExposedHeaders: []string{"Link"},