在创建 API 时,若勾选了支持 CORS,则 API 网关支持跨域请求,默认配置如下:
<dx-codeblock>
::: plaintext
#define CORS_DEFAULT_AC_ALLOW_ORIGIN ("*")
#define CORS_DEFAULT_AC_ALLOW_METHODS ("GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH")
#define CORS_DEFAULT_AC_ALLOW_CREDENTIALS ("true")
#define CORS_DEFAULT_AC_ALLOW_HEADERS ("X-Api-ID,X-Service-RateLimit,X-UsagePlan-RateLimit,X-UsagePlan-Quota,Cache- Control,Connection,Content-Disposition,Date,Keep-Alive,Pragma,Via,Accept,Accept-Charset,Accept-Encoding,Accept-Language,Authorization,Cookie,Expect,From,Host,If-Match,If-Modified-Since,If-None-Match,If-Range,If-Unmodified-Since,Range,Origin,Referer,User-Agent,X-Forwarded-For,X-Forwarded-Host,X-Forwarded-Proto,Accept-Range,Age,Content-Range,Content-Security-Policy,ETag,Expires,Last-Modified,Location,Server,Set-Cookie,Trailer,Transfer-Encoding,Vary,Allow,Content-Encoding,Content-Language,Content-Length,Content-Location,Content-Type")
#define CORS_DEFAULT_AC_EXPOSE_HEADERS (CORS_DEFAULT_AC_ALLOW_HEADERS)
#define CORS_DEFAULT_AC_MAX_AGE ("86400")
:::
</dx-codeblock>...
展开详请