@@ 402,6 402,16 @@ func (br *bridge) handleWebhooks(w http.ResponseWriter, r *http.Request) {
}
}
+func (br *bridge) corsMiddleware(handler http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Access-Control-Allow-Origin", "*")
+ w.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
+ w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
+
+ handler.ServeHTTP(w, r)
+ })
+}
+
func (br *bridge) authMiddleware(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
logger := br.logger.With(slog.String("url", r.URL.String()))
@@ 495,6 505,8 @@ func main() {
httpServer.Handler = bridge.authMiddleware(mux)
}
+ httpServer.Handler = bridge.corsMiddleware(httpServer.Handler)
+
if _, ok := c.(*cache.MemoryCache); ok {
go bridge.runCleanup(ctx)
}