我正在尝试使用openapi: 3.0.1
格式测试我的API文档。尝试从SwaggerHub文档执行端点时,出现以下标题的403错误:
content-length: 0
date: Thu, 11 Oct 2018 04:28:28 GMT
server: nginx/1.8.0 + Phusion Passenger 5.0.22
status: 403 Forbidden
x-powered-by: Express, Phusion Passenger 5.0.22
此问题既适用于Safari浏览器,也适用于Chrome浏览器。
我还按照以下代码段为我的golang应用程序启用了CORS
:
allowedOrigins := handlers.AllowedOrigins([]string{"*"})
allowedHeaders := handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization", "Accept"})
allowedMethods := handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "OPTIONS"})
log.Fatal(http.ListenAndServe(":3030", handlers.CORS(allowedOrigins, allowedHeaders, allowedMethods)(router)))
还根据此article为CORS启用了浏览器安全性。