mirror of
https://github.com/Unkn0wnCat/calapi.git
synced 2025-05-25 05:36:09 +02:00
Add CORS
This commit is contained in:
parent
6d7a998c45
commit
5b9ab0e163
3 changed files with 12 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/Unkn0wnCat/calapi/internal/logger"
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/go-chi/chi/middleware"
|
||||
"github.com/go-chi/cors"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"go.uber.org/zap"
|
||||
"net/http"
|
||||
|
@ -55,6 +56,14 @@ func Serve() {
|
|||
router.Use(middleware.RequestID)
|
||||
router.Use(logMiddleware)
|
||||
router.Use(middleware.Recoverer)
|
||||
router.Use(cors.Handler(cors.Options{
|
||||
AllowedOrigins: []string{"https://*", "http://*"},
|
||||
AllowedMethods: []string{"GET", "POST", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
||||
//ExposedHeaders: []string{"Link"},
|
||||
AllowCredentials: false,
|
||||
MaxAge: 300,
|
||||
}))
|
||||
router.Use(auth.Middleware())
|
||||
|
||||
srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue