railsのローカル環境からapigatewayを下記のように叩いています。
(ボタンでajaxをキックして動かす。)
$.ajax url: gon.apigateway_url+"path?query_params="+params type: 'GET' headers: {'x-api-key': gon.apigateway_api_key}
すると下記のようなエラーが出ます。
Access to XMLHttpRequest at 'apigateway_url' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'https://xxx(本番環境のURL)' that is not equal to the supplied origin.
chrome拡張の
Allow-Control-Allow-Origin: *
を入れて起動して実行すると、
Access to XMLHttpRequest at 'apigateway_url' from origin 'http://localhost:3000' has been blocked by CORS policy: : Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values 'https://xxx(本番環境のURL), *', but only one is allowed.
となります。
Access-Control-Allow-OriginのURL設定がどこでできるのか分からないのですが、'https://xxx(本番環境のURL)'を外す箇所を教えていただけないでしょうか?
ちなみにapigateway側のCROSのAccess-Control-Allow-Originも "*"になっています。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/16 00:07