From 3c67d693ed6b643d027de39ff03047d70430d070 Mon Sep 17 00:00:00 2001 From: Chirag Ghosh Date: Mon, 17 Jun 2024 11:02:37 +0530 Subject: [PATCH] fix: update cors Signed-off-by: Chirag Ghosh --- main.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 4ed0684..61f1ea9 100644 --- a/main.go +++ b/main.go @@ -332,11 +332,18 @@ func main() { initMailer() + generalCors := cors.New(cors.Options{ + AllowedOrigins: []string{"http://localhost:5173", "https://heimdall.metakgp.org"}, + AllowCredentials: true, + }) + + specialCors := cors.AllowAll() + mux := http.NewServeMux() - mux.HandleFunc("/campus-check", handleCampusCheck) - mux.HandleFunc("/get-otp", handleGetOtp) - mux.HandleFunc("/verify-otp", handleVerifyOtp) - mux.HandleFunc("/validate-jwt", handleValidateJwt) + mux.Handle("/campus-check", specialCors.Handler(http.HandlerFunc(handleCampusCheck))) + mux.Handle("/get-otp", generalCors.Handler(http.HandlerFunc(handleGetOtp))) + mux.Handle("/verify-otp", generalCors.Handler(http.HandlerFunc(handleVerifyOtp))) + mux.Handle("/validate-jwt", generalCors.Handler(http.HandlerFunc(handleValidateJwt))) handler := cors.AllowAll().Handler(mux)