Fix cors
This commit is contained in:
18
src/main.go
18
src/main.go
@@ -11,6 +11,8 @@ import (
|
|||||||
|
|
||||||
"github.com/gin-contrib/cors"
|
"github.com/gin-contrib/cors"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -44,6 +46,22 @@ func main() {
|
|||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
corsConfig := cors.DefaultConfig()
|
corsConfig := cors.DefaultConfig()
|
||||||
corsConfig.AllowOrigins = []string{"https://sheets.julian-mutter.de"}
|
corsConfig.AllowOrigins = []string{"https://sheets.julian-mutter.de"}
|
||||||
|
corsConfig.AllowHeaders = []string{
|
||||||
|
"Origin",
|
||||||
|
"X-Requested-With",
|
||||||
|
"Content-Type",
|
||||||
|
"Accept",
|
||||||
|
"Authorization",
|
||||||
|
}
|
||||||
|
corsConfig.AllowMethods = []string{
|
||||||
|
http.MethodHead,
|
||||||
|
http.MethodGet,
|
||||||
|
http.MethodPost,
|
||||||
|
http.MethodPut,
|
||||||
|
http.MethodPatch,
|
||||||
|
http.MethodDelete,
|
||||||
|
}
|
||||||
|
corsConfig.AllowCredentials = true
|
||||||
|
|
||||||
router.Use(cors.New(corsConfig))
|
router.Use(cors.New(corsConfig))
|
||||||
routes.SetupRoutes(router)
|
routes.SetupRoutes(router)
|
||||||
|
|||||||
Reference in New Issue
Block a user