#8 add view and api to track activities

This commit is contained in:
2024-07-27 21:10:31 +02:00
parent 98c6f57008
commit 5d54e72744
12 changed files with 625 additions and 54 deletions

20
api/middleware/cors.go Normal file
View File

@@ -0,0 +1,20 @@
package middleware
import (
"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", "http://localhost:5173")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, DELETE")
w.Header().Set("Access-Control-Allow-Headers", "Authorization")
if r.Method == "OPTIONS" {
w.WriteHeader(http.StatusOK)
return
}
next.ServeHTTP(w, r)
})
}