为什么我的无服务器 Lambda 函数拒绝 Cache-Control header?
Why does my serverless Lambda function reject Cache-Control header?
我正在使用 FineUploader 将文件上传到 S3。使用 DELETE 功能时出现以下错误:
XMLHttpRequest cannot load
https://xxxxxxx.execute-api.us-east-1.amazonaws.com/prod/deleteS3File?.
Request header field Cache-Control is not allowed by
Access-Control-Allow-Headers in preflight response.
lambda 函数是使用具有以下配置的出色无服务器框架创建的:
functions:
deleteS3File:
handler: handler.deleteS3File
events:
- http:
path: deleteS3File
method: POST
integration: lambda
cors: true
response:
headers:
Access-Control-Allow-Origin: "*"
知道这个错误对 Lambda 函数意味着什么以及如何解决它吗?
您不支持的POST verb preflights an OPTIONS verb。
因此,您需要为 OPTIONS 创建一个方法,该方法将 return 状态代码 200(成功)并具有预期的 headers.
对于 OPTIONS 和 POST,请尝试以下 headers:
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: "GET, HEAD, OPTIONS, POST, PUT, DELETE"
Access-Control-Allow-Headers: "Access-Control-Allow-Headers, Cache-Control, Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"
你可以稍后微调 headers 以允许你需要的
我正在使用 FineUploader 将文件上传到 S3。使用 DELETE 功能时出现以下错误:
XMLHttpRequest cannot load https://xxxxxxx.execute-api.us-east-1.amazonaws.com/prod/deleteS3File?. Request header field Cache-Control is not allowed by Access-Control-Allow-Headers in preflight response.
lambda 函数是使用具有以下配置的出色无服务器框架创建的:
functions:
deleteS3File:
handler: handler.deleteS3File
events:
- http:
path: deleteS3File
method: POST
integration: lambda
cors: true
response:
headers:
Access-Control-Allow-Origin: "*"
知道这个错误对 Lambda 函数意味着什么以及如何解决它吗?
您不支持的POST verb preflights an OPTIONS verb。
因此,您需要为 OPTIONS 创建一个方法,该方法将 return 状态代码 200(成功)并具有预期的 headers.
对于 OPTIONS 和 POST,请尝试以下 headers:
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: "GET, HEAD, OPTIONS, POST, PUT, DELETE"
Access-Control-Allow-Headers: "Access-Control-Allow-Headers, Cache-Control, Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"
你可以稍后微调 headers 以允许你需要的