mirror of
https://github.com/LiteyukiStudio/spage.git
synced 2026-01-26 13:42:25 +00:00
19 lines
490 B
Go
19 lines
490 B
Go
package middle
|
|
|
|
import (
|
|
"github.com/cloudwego/hertz/pkg/app"
|
|
"github.com/hertz-contrib/cors"
|
|
)
|
|
|
|
func Cors() app.HandlerFunc {
|
|
return cors.New(
|
|
cors.Config{
|
|
AllowOrigins: []string{"*"},
|
|
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"},
|
|
AllowHeaders: []string{"*"},
|
|
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers"},
|
|
AllowCredentials: true,
|
|
MaxAge: 3600,
|
|
})
|
|
}
|