CORSヘッダーのPOST
ラムダプロキシメソッドとOPTIONS
メソッドを持つAPIGatewayリソースを設定しました。AWS APIGateway CORS for Lambda Proxyは適用されません
OPTIONS
方法は、これらのヘッダを返します。私は、生成されるJavaScript SDKでPOST
エンドポイントを呼び出すとき
$ curl -i -X OPTIONS https://xxxxxxxxx.execute-api.eu-central-1.amazonaws.com/dev/endpoint1
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: keep-alive
Date: Sat, 18 Feb 2017 17:07:17 GMT
x-amzn-RequestId: xxxx
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
Access-Control-Allow-Methods: POST,OPTIONS
X-Cache: Miss from cloudfront
Via: 1.1 xxxx.cloudfront.net (CloudFront)
X-Amz-Cf-Id: xxxx==
はまだ、Chromeブラウザのコンソールは、このエラーを示しています
XMLHttpRequest cannot load https://xxxx.execute-api.eu-central-1.amazonaws.com/dev/endpoint1.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access.
だけでなく、Firefoxの:
Cross-Origin Request Blocked:
The Same Origin Policy disallows reading the remote resource at https://xxxx.execute-api.eu-central-1.amazonaws.com/dev/endpoint1.
(Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
なぜm y CORSヘッダーは考慮されていませんか? POSTメソッドの設定を変更する必要はありますか?
。 'http:// lvh.me'または' http:// www.127.0.0.1.xip.io'を使ってあなたのサイトをテストしてください。これらはlocalhostのエイリアスですが、ブラウザはそのことを認識しません。 –