feat: enable CORS for REST API (#1067)

This commit is contained in:
Prem Chaitanya Prathi 2024-03-26 19:13:50 +05:30 committed by GitHub
parent b199b08ed6
commit 53e0ea6ac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -38,7 +38,12 @@ func NewWakuRest(node *node.WakuNode, config RestConfig, log *zap.Logger) *WakuR
mux := chi.NewRouter() mux := chi.NewRouter()
mux.Use(middleware.Logger) mux.Use(middleware.Logger)
mux.Use(middleware.NoCache) mux.Use(middleware.NoCache)
mux.Use(func(h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
}
return http.HandlerFunc(fn)
})
if config.EnablePProf { if config.EnablePProf {
mux.Mount("/debug", middleware.Profiler()) mux.Mount("/debug", middleware.Profiler())
} }