1. configuration := Abstractions.NewConfigurationBuilder().AddYamlFile("config").Build()
  2. YoyoGo.NewWebHostBuilder().
  3. UseConfiguration(configuration).
  4. Configure(func(app *YoyoGo.WebApplicationBuilder) {
  5. app.UseMiddleware(Middleware.NewCORS())
  6. })
  7. //......
  8. //......

在配置文件中开启CORS

application.server.cors :

  1. application:
  2. server:
  3. cors:
  4. enable: true
  5. allow_origins: [ "*" ]
  6. allow_methods: [ "POST","GET","PUT", "PATCH" ]
  7. allow_credentials: true