From b1e06cf673cef22ab2a2d4a6bf37098968152605 Mon Sep 17 00:00:00 2001 From: Arzumify Date: Tue, 15 Oct 2024 19:39:16 +0100 Subject: [PATCH] Disable CORS Signed-off-by: Arzumify --- services-src/auth/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services-src/auth/main.go b/services-src/auth/main.go index 3550a6c..e9473f6 100644 --- a/services-src/auth/main.go +++ b/services-src/auth/main.go @@ -344,6 +344,18 @@ func Main(information library.ServiceInitializationInformation) *chi.Mux { // Set up the router router := chi.NewRouter() + // Add the CORS middleware + disableCors := func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + next.ServeHTTP(w, r) + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Headers", "*") + w.Header().Set("Access-Control-Allow-Methods", "*") + }) + } + + router.Use(disableCors) + // Set up the static routes staticDir, err := fs.Sub(information.ResourceDir, "static") if err != nil {