CORS
This commit is contained in:
@@ -1,12 +1,27 @@
|
||||
package endpoints
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Run() {
|
||||
r := gin.Default()
|
||||
|
||||
r.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{"http://localhost:4000"},
|
||||
AllowMethods: []string{"GET", "POST", "DELETE", "PATCH"},
|
||||
AllowHeaders: []string{"Origin", "Content-Type"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
AllowOriginFunc: func(origin string) bool {
|
||||
return origin == "http://localhost:4000"
|
||||
},
|
||||
MaxAge: 12 * time.Hour,
|
||||
}))
|
||||
|
||||
public := r.Group("/")
|
||||
|
||||
public.POST("/login", login) //web login
|
||||
|
||||
Reference in New Issue
Block a user