I use the fetch-node@2 version, and whenever I try to access the Google API, the response time is tremendously and painfully slow. I’m literally waiting 6-8 seconds to retrieve the data. On the other hand, whenever I use the fetch function inside the browser, the response time is just fine, somewhere between 800ms to 1.5s, nothing out of the ordinary.
Here is the simple code:
await (await fetch(`https://www.googleapis.com/userinfo/v2/me`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`
}
})).json();
How come it takes so much time in the backend? I’ve also tried axios and the native HTTPS library, and they both yield the same horrible result.
I’m working on a sign-in via a Google account, and I definitely can’t allow obtaining that data from the client side and shipping it to the backend, despite the good response time. It must get handled by the backend but I can’t have an absurd 8-second wait time on the backend..
And for the record, I use only 2 scopes: userinfo.profile and userinfo.email.
Is there any reasonable explanation for why this happens and, most importantly, how to solve it?