From 0a1bdc19f3aa80c1facd9c4d7a2f1357ea760c23 Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Wed, 2 Sep 2020 20:30:23 -0500 Subject: [PATCH] fix: remove cors middleware fixes #51 --- go.mod | 1 - go.sum | 2 -- internal/route/route.go | 13 ------------- 3 files changed, 16 deletions(-) diff --git a/go.mod b/go.mod index 76ecd33..1dbc979 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/99designs/gqlgen v0.11.3 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/go-chi/chi v3.3.2+incompatible - github.com/go-chi/cors v1.0.0 github.com/golang-migrate/migrate/v4 v4.11.0 github.com/golang/protobuf v1.3.4 // indirect github.com/google/uuid v1.1.1 diff --git a/go.sum b/go.sum index 6d69345..c077f39 100644 --- a/go.sum +++ b/go.sum @@ -109,8 +109,6 @@ github.com/fsouza/fake-gcs-server v1.17.0/go.mod h1:D1rTE4YCyHFNa99oyJJ5HyclvN/0 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-chi/chi v3.3.2+incompatible h1:uQNcQN3NsV1j4ANsPh42P4ew4t6rnRbJb8frvpp31qQ= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= -github.com/go-chi/cors v1.0.0 h1:e6x8k7uWbUwYs+aXDoiUzeQFT6l0cygBYyNhD7/1Tg0= -github.com/go-chi/cors v1.0.0/go.mod h1:K2Yje0VW/SJzxiyMYu6iPQYa7hMjQX2i/F491VChg1I= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= diff --git a/internal/route/route.go b/internal/route/route.go index 5fda6c2..6566736 100644 --- a/internal/route/route.go +++ b/internal/route/route.go @@ -6,7 +6,6 @@ import ( "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" - "github.com/go-chi/cors" "github.com/jmoiron/sqlx" log "github.com/sirupsen/logrus" @@ -73,18 +72,6 @@ func NewRouter(dbConnection *sqlx.DB) (chi.Router, error) { routerLogger.SetLevel(log.InfoLevel) routerLogger.Formatter = formatter r := chi.NewRouter() - cors := cors.New(cors.Options{ - // AllowedOrigins: []string{"https://foo.com"}, // Use this to allow specific origin hosts - AllowedOrigins: []string{"*"}, - // AllowOriginFunc: func(r *http.Request, origin string) bool { return true }, - AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, - AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token", "Cookie"}, - ExposedHeaders: []string{"Link"}, - AllowCredentials: true, - MaxAge: 300, // Maximum value not ignored by any of major browsers - }) - - r.Use(cors.Handler) r.Use(middleware.RequestID) r.Use(middleware.RealIP) r.Use(logger.NewStructuredLogger(routerLogger))