Skip to content
This repository has been archived by the owner on Jan 26, 2023. It is now read-only.

Commit

Permalink
setup credential request correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
camallen committed Nov 22, 2019
1 parent 05c66ef commit ac2a05c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/make-http-request.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ request.parse[DEFAULT_HEADERS['Accept']] = JSON.parse.bind JSON
# isolate the credential requests from the superagent singleton
# via the agent() to ensure correct credentials for both request types
# http://visionmedia.github.io/superagent/#agents-for-global-state
if request.agent? && request.withCredentials?
credentialRequest = request.agent().withCredentials()
if request.agent?
credentialRequest = request.agent()
if credentialRequest.withCredentials?
credentialRequest = credentialRequest.withCredentials()
else
# ensure the credentialRequest is set, though it would use the
# singleton superagent and fail to correctly send credential requests
credentialRequest = request

makeHTTPRequest = (method, url, data, headers = {}, query) ->
makeRequest(request, method, url, data, headers, query)
Expand Down

0 comments on commit ac2a05c

Please sign in to comment.