Nextjs Server-side redirect not working when deployed to AWS

I have this server side page component. It basically takes the result of the api response and the redirects accordingly. Everything works as expected on local but as soon as i deploy it to our UAT environment on aws the redirect URL isn’t updating as if it’s never entering the try/catch the final redirect is the one still set outside the try catch block.

import VerifyEmailPageBody from "@/app/(body)/register/VerifyEmailPageBody";
import { notFound, redirect } from "next/navigation";

import { RequestRegisterUserConfirmFetch } from "@/api/services/registerUserServer.api";


const VerifyEmailPage = async ({
  searchParams,
}: {
  searchParams?: { [key: string]: string | string[] | undefined };
}) => {
  const code = searchParams?.code;
  const email = searchParams?.email;
  const expirationTime = searchParams?.expirationTime;

  if (!code) {
    return <VerifyEmailPageBody />;
  }

  const redirectPath =
    "/register/expired?email=" + encodeURIComponent(email as string);

  if (expirationTime) {
    const currentEpochTime = Math.floor(Date.now() / 1000);
    if (currentEpochTime > Number(expirationTime)) {
      return redirect(redirectPath);
    }
  }

  let redirectPathVerify: string = "/register/verify";

  try {
    // check token request
    await RequestRegisterUserConfirmFetch({
      secureToken: (code as string) || "",
    });

    redirectPathVerify = "/register/success/";

  } catch (err: unknown) {
    const errorStatus = (err as Record<string, { status: number }>)?.response
      ?.status;

    if (errorStatus === 410) {
      redirectPathVerify = redirectPath;
    }

    if (errorStatus === 500) {
      redirectPathVerify = "/login/";
    }
    return notFound();
  } finally {
    return redirect(redirectPathVerify);
  }
};

export default VerifyEmailPage;

The api call

"use server";

import { IRequestRegisterUserConfirm } from "@/api/types/registerUser.types";
import { ENV_CONSTANTS } from "@/common/constants/env.const";

export async function RequestRegisterUserConfirmFetch(
  secureToken: IRequestRegisterUserConfirm,
) {
  const baseUrl = "user/registration";
  const response = await fetch(
    `${ENV_CONSTANTS.API_BASEURL}${baseUrl}/confirmation`,
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${ENV_CONSTANTS.DEFAULT_API_BEARER_TOKEN}`,
        "Content-Type": "application/json",
      },
      cache: "no-store",
      body: JSON.stringify(secureToken),
    },
  );

  console.log(response);
  if (response.status === 202) {
    return { status: 202 };
  }

  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  }

  return response;
}

I’ve tried it on local and it works as expected but when deployed to AWS it doesn’t work as expected