add provisional CORS support
This commit is contained in:
10
api/api.go
10
api/api.go
@@ -9,6 +9,7 @@ import (
|
||||
"git.dubyatp.xyz/chat-api-server/db"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/go-chi/cors"
|
||||
"github.com/go-chi/docgen"
|
||||
"github.com/go-chi/render"
|
||||
)
|
||||
@@ -34,6 +35,15 @@ func Start() {
|
||||
|
||||
r := chi.NewRouter()
|
||||
|
||||
r.Use(cors.Handler(cors.Options{
|
||||
AllowedOrigins: []string{"http://localhost:5000"},
|
||||
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
|
||||
ExposedHeaders: []string{"Link"},
|
||||
AllowCredentials: true,
|
||||
MaxAge: 300, // Maximum value for preflight request cache
|
||||
}))
|
||||
|
||||
r.Use(middleware.RequestID)
|
||||
r.Use(RequestLog)
|
||||
r.Use(middleware.Recoverer)
|
||||
|
Reference in New Issue
Block a user