configuration := Abstractions.NewConfigurationBuilder().AddYamlFile("config").Build()
YoyoGo.NewWebHostBuilder().
UseConfiguration(configuration).
Configure(func(app *YoyoGo.WebApplicationBuilder) {
app.UseMiddleware(Middleware.NewCORS())
})
//......
//......
# 在配置文件中开启CORS
application.server.cors :
application:
server:
cors:
enable: true
allow_origins: [ "*" ]
allow_methods: [ "POST","GET","PUT", "PATCH" ]
allow_credentials: true