Commit cd57883b authored by Benjamin Rokseth's avatar Benjamin Rokseth
Browse files

Add Cors

parent ac8915a3
......@@ -17,6 +17,7 @@ import (
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/cors"
minio "github.com/minio/minio-go"
//"github.com/h2non/bimg" // TODO: image processing -- sudo apt install libvips-tools
)
......@@ -47,6 +48,16 @@ func (s *server) ListenAndServe(addr string) error {
func (s *server) setupRouter() *chi.Mux {
r := chi.NewRouter()
cors := cors.New(cors.Options{
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"},
ExposedHeaders: []string{"Link", "Location"},
AllowCredentials: true,
MaxAge: 300, // Maximum value not ignored by any of major browsers
})
r.Use(cors.Handler)
r.Use(
middleware.Logger, // TODO remove when going live - too much noise
middleware.DefaultCompress,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment