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 1 year has passed since last update.

Dockerのネットワーク作成によって、何をしてもCORSエラーが変わらない問題とバトルした(解決済み)

Last updated at Posted at 2023-12-26

起きたこと

samでyamlに書かれている通りにapi gatewayを構築して、go言語で書かれたLambdaを使ってAPIを作成するが、Lambda側でもyaml側でもcorsの許可設定しているのに、何をやってもcorsエラーが変わらなかった。

環境構築資料の通りに進めていたが、そのブランチが古いことを後から知り、最新のブランチのREADME.mdにある手順でやっても他の人は成功するのに自分だけうまくいかなかった。

色々調べて、ほとんどの記事は「corsを許可したらいける」で、一部「"*"だとうまくいかないので直接指定する必要がある」という記事とか色々あったが、どれも関係はなかった。

解決方法

古い手順の中で、docker network createしていたのが原因だった。このネットワークのせいでyaml側とLambdaのheaderでの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?