This repository has been archived on 2025-08-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
web-app-template/middleware/cors.go
Tim 89bc723427
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
Build and Push Docker Image / Explore-Gitea-Actions (push) Successful in 52s
feat(mail): #132 unify env variables and send mails with smtp
2024-09-06 19:09:25 +02:00

23 lines
423 B
Go

package middleware
import (
"me-fit/utils"
"net/http"
)
func EnableCors(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", utils.BaseUrl)
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, DELETE")
if r.Method == "OPTIONS" {
w.WriteHeader(http.StatusOK)
return
}
next.ServeHTTP(w, r)
})
}