add CORS to api

This commit is contained in:
saji 2024-03-04 20:40:55 -06:00
parent a015911e0e
commit bcd61321e6

View file

@ -80,6 +80,7 @@ func TelemRouter(log *slog.Logger, broker *Broker, db *TelemDb) http.Handler {
r.Use(middleware.RealIP) r.Use(middleware.RealIP)
r.Use(middleware.Logger) // TODO: integrate with slog instead of go default logger. r.Use(middleware.Logger) // TODO: integrate with slog instead of go default logger.
r.Use(middleware.Recoverer) r.Use(middleware.Recoverer)
r.Use(middleware.SetHeader("Access-Control-Allow-Origin", "*"))
// heartbeat request. // heartbeat request.
r.Get("/ping", func(w http.ResponseWriter, r *http.Request) { r.Get("/ping", func(w http.ResponseWriter, r *http.Request) {