401 [POST] "https://api.backend.com/v1/users/token": 401 Unauthorized


I am trying to fetch a token on a 3rd party endpoint, I am passing everything correctly, with API keys, content type etc.

Locally on my machine works, and on other cloud providers (digital ocean apps platform|) works, but when I do this through cloudflare pages, it does not work; it returns

401 [POST] "https://api.backend.com/v1/users/token": 401 Unauthorized

Any idea why this might happen? I am attaching snippet of the code I am running

export default eventHandler(async (event) => {
  const response = await $fetch("https://api.backend.com/v1/users/token", {
    method: "POST",
    headers: {
      authorization: `Bearer TEST_API_KEY`,
      accept: "application/json",
      "content-type": "application/json",
    body: {
      userId: "28480b199586d",
  return response;