|
|
@@ -2,6 +2,7 @@ package router
|
|
|
|
|
|
import (
|
|
|
"github.com/go-chi/chi"
|
|
|
+ "github.com/go-chi/cors"
|
|
|
"github.com/porter-dev/porter/server/api"
|
|
|
"github.com/porter-dev/porter/server/requestlog"
|
|
|
"github.com/porter-dev/porter/server/router/middleware"
|
|
|
@@ -15,6 +16,15 @@ func New(a *api.App) *chi.Mux {
|
|
|
r.Route("/api", func(r chi.Router) {
|
|
|
r.Use(middleware.ContentTypeJSON)
|
|
|
|
|
|
+ r.Use(cors.Handler(cors.Options{
|
|
|
+ AllowedOrigins: []string{"*"},
|
|
|
+ AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
|
|
+ AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
|
|
|
+ ExposedHeaders: []string{"Link"},
|
|
|
+ AllowCredentials: false,
|
|
|
+ MaxAge: 300, // Maximum value not ignored by any of major browsers
|
|
|
+ }))
|
|
|
+
|
|
|
// /api/users routes
|
|
|
r.Method("GET", "/users/{id}", requestlog.NewHandler(a.HandleReadUser, l))
|
|
|
r.Method("GET", "/users/{id}/clusters", requestlog.NewHandler(a.HandleReadUserClusters, l))
|