From 53b246a6df4a0b56f98e64b40bb5138c40117734 Mon Sep 17 00:00:00 2001 From: 123niel Date: Thu, 7 Feb 2019 12:13:32 +0100 Subject: [PATCH] added Cors-Header --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 0d28d9f..1480e3f 100644 --- a/main.go +++ b/main.go @@ -16,16 +16,23 @@ import ( "git.cliffbreak.de/Cliffbreak/tsviewer/service" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" + "github.com/go-chi/cors" ) func Routes(s service.Service, t template.Template) *chi.Mux { router := chi.NewRouter() + cors := cors.New(cors.Options{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{"Get"}, + }) router.Use( middleware.Logger, middleware.Timeout(5*time.Second), middleware.DefaultCompress, middleware.RedirectSlashes, middleware.Recoverer, + + cors.Handler, ) router.Route("/v1", func(r chi.Router) {