mirror of
https://github.com/Unkn0wnCat/matrix-veles.git
synced 2025-06-08 13:42:01 +02:00
Add CORS policy to API
This commit is contained in:
parent
ebe9482a27
commit
aa55cd834f
3 changed files with 13 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
chiprometheus "github.com/766b/chi-prometheus"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/cors"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
@ -13,6 +14,15 @@ import (
|
|||
func SetupAPI() chi.Router {
|
||||
router := chi.NewRouter()
|
||||
|
||||
router.Use(cors.Handler(cors.Options{
|
||||
AllowedOrigins: []string{"http://*", "https://*"},
|
||||
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
|
||||
ExposedHeaders: []string{"Link"},
|
||||
AllowCredentials: false,
|
||||
MaxAge: 300,
|
||||
}))
|
||||
|
||||
m := chiprometheus.NewMiddleware("api")
|
||||
router.Use(m)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue