Open carlosconnected opened 7 years ago
Figured it out. The client wasn't the problem. Custom headers require extra configuration when doing CORS. Issue was on the server because my API was missing one line of configuration: headers: :any, expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'], // Was missing this line. methods: [:get, :post, :put, :patch, :delete, :options, :head]
Yeah I'm having the same problem too, and from what I see you're using the rack-cors
gem in a rails project as I do. :)
I was having the same problem using the redux-auth
library that uses this library to make API calls, but turns out the problem was not any of these, was in the API as you mentioned, but I'm not missing this line, the problem is with the file://
protocol used by the electron app. Hope this comment helps anyone searching for these kind of error( it took some long days searching for the bug )
I'm getting a successful response (200) with all the body data but the header is empty. When I try it with curl or postman I can see the headers, but fetch gets me an empty header.
fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: data}) .then(checkStatus) .then(response => response.headers ); // response.json() gets me body data
Is anybody retrieving headers successfully with isomorphic-fetch?