From a2f640db146afbfa540688ea45ebeb73d0ebe75a Mon Sep 17 00:00:00 2001 From: Angelo Capossele <angelocapossele@gmail.com> Date: Mon, 13 Jul 2020 14:43:58 +0100 Subject: [PATCH] CORS: AllowOrigins from anywhere (#640) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🙈 CORS: AllowOrigins from anywhere * 🔧 Add default config to CORS configuration --- plugins/webapi/plugin.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index 24074bf6..d96f0fe1 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -13,6 +13,7 @@ import ( "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" + "github.com/labstack/echo/middleware" ) // PluginName is the name of the web API plugin. @@ -41,6 +42,11 @@ func Plugin() *node.Plugin { func Server() *echo.Echo { serverOnce.Do(func() { server = echo.New() + server.Use(middleware.CORSWithConfig(middleware.CORSConfig{ + Skipper: middleware.DefaultSkipper, + AllowOrigins: []string{"*"}, + AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete}, + })) }) return server } -- GitLab