2016-11-28 7 views
2

すべてのボディデータで正常な応答(200)が得られましたが、ヘッダーは空です。応答ヘッダーには、将来の要求に必要なアクセストークンがあります。私がカールか郵便配達でそれを試すと、私はヘッダーを見ることができますが、同形フェッチは私に空のヘッダーを与えます。同形フェッチを使用したレスポンスからのヘッダー

fetch(endpoint, { 
    method: 'POST', 
    headers: { 
     'Content-Type': 'application/json' 
    }, 
    body: data}) 
.then(checkStatus) 
.then(response => response.headers); // response.json() gets me body data 

誰かがisomorphic-fetchで正常にヘッダーを取得していますか?

答えて

2

クライアントは問題ではありませんでした。カスタムヘッダーは、CORSを実行するときに特別な設定が必要です。私のAPIに1行の設定が欠落していたため、問題がサーバー上にありました:

headers: :any, 
expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'], # Was missing this line. 
methods: [:get, :post, :put, :patch, :delete, :options, :head] 
関連する問題