お世話になっております。
現在、
・cordova
・vue.js
を使用してハイブリッドアプリを構築しており、アプリ内でAPI接続を複数行なっているのですが、3回に1回の頻度でCORSのエラーが発生してしまいます。
API接続はaxiosのpostメソッドを使用しております。
サーバー側のレスポンスの設定に不備があるのか、
もしくは処理が遅延している時に発生するのか等、理由が分かり兼ねており、
もしお分かりの方がいらっしゃりましたら、お知恵をお借りできますと幸いでございます。
宜しくお願い致します。
<googleの開発環境のconsoleで表示されるエラー>
Failed to load https://hogehoge.info/api/hoge/hogehoge: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
<APIサーバー側でセットしている内容>
header('Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS'); header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Range, ' . 'Content-Disposition, Content-Type, Authorization'); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Origin: *'); header('Content-type: application/json'); header("Access-Control-Allow-Headers","Content-Type"); header("Access-Control-Max-Age", "86400");
<クライアント側のリクエスト等>
●General * Request URL: https://hogehoge.info/api/hoge/hogehoge * Request Method: POST * Status Code: 200 OK * Remote Address: hogehoge * Referrer Policy: no-referrer-when-downgrade * Response Headers * Access-Control-Allow-Credentials: true * Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Range, Content-Disposition, Content-Type, Authorization * Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS * Access-Control-Allow-Origin: * * Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 * Connection: keep-alive * Content-Encoding: gzip * Content-Length: 327 * Content-Type: application/json * Date: Mon, 17 Sep 2018 20:24:54 GMT * Expires: Thu, 19 Nov 1981 08:52:00 GMT * Pragma: no-cache * Server: Apache * Vary: Accept-Encoding * X-Content-Security-Policy: default-src 'self' * X-Content-Type-Options: nosniff * X-Frame-Options: DENY * X-XSS-Protection: 1; mode=block * Request Headers * Provisional headers are shown * Accept: application/json, text/plain, */* * Content-Type: application/x-www-form-urlencoded;charset=UTF-8 * Origin: http://localhost:8080 * Referer: http://localhost:8080/ * User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 * Form Dataview source view URL encoded * lang: ja * api_key: hogehoge * access_token: [object Promise]
どうぞ宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。