0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

url scheme must be http or https for cors requestのエラー

Last updated at Posted at 2021-08-24

作業環境

  • AWS API Gateway
  • AWS Lambda
  • swagger(Open API)

トラブルの内容

  • swaggerで発生するエラーです。
  • swaggerでhttpメソッド(get,putなど)の「execute」ボタンを押下したら、url scheme must be http or https for cors requestというエラーが発生しました。

解決方法

  • AWS API Gatewayで「CORSの有効化」をしていなかったことが原因でした。
    • リソースを選択した後、アクションのドロップダウンから「CORSの有効化」を選択することができます。
    • CORSを有効化した後は、APIをデプロイするのも忘れないようにしましょう。

参考ページ

感想

  • 自分の作業した流れは、以下の通りです。
    • Lambda単体で正しいレスポンスが返ってくることを確認する。
    • API Gatewayとlambdaを連携してAPI GatewayでテストしてLambdaが正しいレスポンスが返ってくることを確認する。
    • swaggerからAPI Gatewayを実行して正しいレスポンスが返ってくることを確認する。
  • このような流れで作業を進めていって、表題のトラブルに遭遇しました。
  • 「CORSとは何か」もっと勉強する必要があると感じました。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?