Skip to content

跨域中间件

YoyoFx edited this page Aug 27, 2020 · 3 revisions

	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