0

So im facing a weird issue while making a request to my api. It works fine using something like postman. I get my response no issue but if I make a request from my frontend(on a seperate domain) the connection gets closed for some reason.

Here is my code

I make ajax request using axios

axios.get(mydomain/api/oauth)
 .then(response => {
   console.log(response)
 }).catch(error => {
 console.log(error.response.data)
})

which hits my backend method that should return a response like so

def oauth(request):
    auth_client = AuthClient(
        settings.CLIENT_ID,
        settings.CLIENT_SECRET,
        settings.REDIRECT_URI,
        settings.ENVIRONMENT
    )

    url = auth_client.get_authorization_url([Scopes.ACCOUNTING])
    request.session['state'] = auth_client.state_token
    return HttpResponse(url)

But at this point I get this alarm

ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

And like I said if I make this same request through postman I get my response. So I don't know what I am missing. I have applied cors thinking maybe its because my frontend is on seperate domain from backend but no luck. Plus the alarm is kind of vague... anybody face similar issue?

TJ Weems
  • 1,086
  • 3
  • 21
  • 37
  • You should see something in the browser console if cors is an issue. Also is it server-side or client-side which is initiating the connection to the OAuth provider? – James Powis Apr 14 '20 at 03:48
  • Yes agreed on the cors comment I just wanted to mention it, and on the server-side.. – TJ Weems Apr 14 '20 at 03:49
  • I am at a loss, everything seems as simple as possible, however,https://stackoverflow.com/questions/17854713/error-errno-10053 might have some relevant information. – James Powis Apr 14 '20 at 04:03

0 Answers0