From 53e0ea6ac67cd4381f20cac8b05d2caa78becae3 Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Tue, 26 Mar 2024 19:13:50 +0530 Subject: [PATCH] feat: enable CORS for REST API (#1067) --- cmd/waku/server/rest/waku_rest.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/waku/server/rest/waku_rest.go b/cmd/waku/server/rest/waku_rest.go index 3126f37e..788982f3 100644 --- a/cmd/waku/server/rest/waku_rest.go +++ b/cmd/waku/server/rest/waku_rest.go @@ -38,7 +38,12 @@ func NewWakuRest(node *node.WakuNode, config RestConfig, log *zap.Logger) *WakuR mux := chi.NewRouter() mux.Use(middleware.Logger) 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 { mux.Mount("/debug", middleware.Profiler()) }