-1

I'm developing a Next.js application hosted on a cloud server (Ubuntu 22.04, Node.js v22.17.0), and I'm using the native fetch (which uses Undici under the hood). When trying to call the LinkedIn API endpoint https://api.linkedin.com/v2/me, I'm encountering the following error:

[cause]: Error
    at makeNetworkError (node:internal/deps/undici/undici:9277:35)
    at httpRedirectFetch (node:internal/deps/undici/undici:10825:32)
    at httpFetch (node:internal/deps/undici/undici:10785:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async node:internal/deps/undici/undici:10522:20
    at async mainFetch (node:internal/deps/undici/undici:10512:20)

Sample code:

const response = await fetch('https://api.linkedin.com/v2/me', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${accessToken}`,
    'Content-Type': 'application/json',
  },
});

Things I've Tried:

  1. Valid OAuth2 access token is being passed (works fine from local dev).

  2. The same fetch request works from my local machine (Mac).

  3. I can curl / telnet / openssl from the server to api.linkedin.com:443 — it connects successfully.

  4. Tested with increased fetch timeout and retries - still fails.

Questions:

  1. What exactly causes makeNetworkError in undici when using fetch with HTTPS?

  2. Why would this work locally but fail on a cloud-hosted server?

  3. Are there any known network restrictions or IP blocks from LinkedIn's side?

  4. Could this be caused by redirect handling or TLS handshake issues?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.