@@ 20,6 20,7 @@ require (
github.com/emersion/go-smtp v0.21.3
github.com/fernet/fernet-go v0.0.0-20211208181803-9f70042a33ee
github.com/go-chi/chi/v5 v5.0.10
+ github.com/go-chi/cors v1.2.2
github.com/go-redis/redis/v8 v8.11.5
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.7.4
@@ 68,6 68,8 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
+github.com/go-chi/cors v1.2.2 h1:Jmey33TE+b+rB7fT8MUy1u0I4L+NARQlK6LhzKPSyQE=
+github.com/go-chi/cors v1.2.2/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
@@ 23,6 23,7 @@ import (
"github.com/99designs/gqlgen/graphql/playground"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
+ "github.com/go-chi/cors"
goRedis "github.com/go-redis/redis/v8"
reuseport "github.com/kavu/go_reuseport"
_ "github.com/lib/pq"
@@ 216,6 217,13 @@ func (server *Server) WithDefaultMiddleware() *Server {
requestsProcessed.Inc()
})
})
+ server.router.Use(cors.Handler(cors.Options{
+ AllowedOrigins: []string{"*"},
+ AllowedMethods: []string{"GET", "POST", "OPTIONS"},
+ AllowedHeaders: []string{"User-Agent", "X-Requested-With", "If-Modified-Since", "Cache-Control", "Content-Type", "Range"},
+ ExposedHeaders: []string{"Content-Length", "Content-Range"},
+ MaxAge: 1728000,
+ }))
server.router.Use(config.Middleware(server.conf, server.service))
server.router.Use(email.Middleware(server.email))
server.router.Use(database.Middleware(db))