package middleware
|
|
|
|
import (
|
|
"github.com/iris-contrib/middleware/cors"
|
|
"github.com/kataras/iris/v12/context"
|
|
|
|
)
|
|
|
|
func Cors() context.Handler {
|
|
crs := cors.New(cors.Options{
|
|
AllowedOrigins: []string{"*"}, //允许通过的主机名称
|
|
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE","OPTIONS"},
|
|
AllowedHeaders: []string{"*"},
|
|
Debug: true,
|
|
AllowCredentials: true,
|
|
})
|
|
return crs
|
|
}
|