2
0

(axiosで)叩いて(corsで)弾いてボタンクリック!!

Posted at

はじめに

フロントからaxiosでバックエンドの処理を実行させたかったが、何度クリックしてもcorsエラーでふせがれてしまった

システム構成

Lambda × serverless構成
フロントからaxiosを叩くことでバックエンドのハンドラーが実行される仕組み

原因と解決

Provisional headers are shown

開発者ツールのネットワークタブを確認すると見たことない表示が…

image.png

結論として、serverless.ymlに記載しているパス名が間違っており、Request URLが間違っていることが原因でした。

  get_hoge:
    handler: get_hoge.handler.main
    layers:
      - Ref: PythonRequirementsLambdaLayer
    events:
     - http:
          method: post
          path: /get_hoge # ここが原因だった
          cors:
            origins:
              - '*'

おわりに

気づくのに時間がかかってしまったのでここに供養します。

2
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
2
0