summaryrefslogtreecommitdiffstats
path: root/api/middleware
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.net>2025-09-09 22:44:09 +0100
committerLeonardo Bishop <me@leonardobishop.net>2025-09-09 22:44:09 +0100
commitf1741a7faa9538e9b12ac60e0fbf6c7721a36059 (patch)
tree2b70b14fc20a8520718910a0cd2e0134790c6f53 /api/middleware
Initial commit
Diffstat (limited to 'api/middleware')
-rw-r--r--api/middleware/cors.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/api/middleware/cors.go b/api/middleware/cors.go
new file mode 100644
index 0000000..926c1ed
--- /dev/null
+++ b/api/middleware/cors.go
@@ -0,0 +1,12 @@
+package middleware
+
+import "net/http"
+
+func Cors(next http.HandlerFunc) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Access-Control-Allow-Origin", "*")
+ w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
+
+ next(w, r)
+ }
+}