# A CORS error appears in the console

**URL:** <https://community.auth0.com/t/a-cors-error-appears-in-the-console/191511>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [September 5, 2025, 12:49pm UTC](https://community.auth0.com/t/a-cors-error-appears-in-the-console/191511 "2025-09-05T12:49:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSK1116](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/msk1116/32/76466_2.png) [@MSK1116](https://community.auth0.com/u/MSK1116)\
**Post date:** [September 5, 2025, 12:49pm UTC](https://community.auth0.com/t/a-cors-error-appears-in-the-console/191511/1 "2025-09-05T12:49:23Z")

</div>

```javascript
// \frontend\src\app\chat\[...slug]\page.jsx
import { notFound, redirect } from "next/navigation";
import mongoDbCreateUser from "@/lib/mongoDbCreateUser";
import ChatWrapper from "@/app/chat/[...slug]/ChatWrapper";
import { auth0 } from "@/lib/auth0";
export async function generateMetadata({ params, searchParams }) {
  const { slug } = await params;
  const searchParamsTemp = await searchParams;
  const initialMessage = searchParamsTemp?.q;
  return {
    metadataBase: new URL(process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:3000"),
    title: `Chat | ${slug ? "Session" : initialMessage ? "New Session" : "bureaucrazy.co"}`,
    icons: {
      icon: "/web/Logo.webp",
      shortcut: "/web/Logo.webp",
      apple: "/web/Logo.webp",
    },
    robots: {
      index: false,
      follow: false,
      nocache: true,
    },
    openGraph: {
      title: "bureaucrazy.co",
      description: "",
      url: "https://www.bureaucrazy.co/",
      siteName: "bureaucrazy.co",
      images: [
        {
          url: "/web/Logo.webp",
          width: 1200,
          height: 630,
          alt: "Bureaucrazy logo",
        },
      ],
      locale: "en_US",
      type: "website",
    },
  };
}

export default async function Page({ params, searchParams }) {
  const { slug } = await params;
  const searchParamsTemp = await searchParams;
  const initialMessage = searchParamsTemp.q;
  const { getUserInfo } = await mongoDbCreateUser();
  const session = await auth0.getSession();
  if (!session) {
    redirect(`/chat/testing/?q=${initialMessage || "Hi bureaucrazy!"}`);
  }
  const chatSession = getUserInfo.sessions.find((data) => data.sessionId == slug);

  if (chatSession) {
    return (
      <>
        <main className=" w-full flex flex-1 relative flex-col justify-between ">
          <ChatWrapper session={session} initialMsg={chatSession} />
        </main>
      </>
    );
  }

  if (!chatSession && initialMessage) {
    return (
      <>
        <main className=" w-full flex flex-1 relative flex-col justify-between ">
          <ChatWrapper session={session} initialMsg={decodeURIComponent(initialMessage)} />
        </main>
      </>
    );
  } else {
    return (
      <>
        <main className=" w-full flex flex-1 relative flex-col justify-between ">{notFound()}</main>
      </>
    );
  }
}

```

```auto
Access to fetch at 'https://auth.bureaucrazy.co/authorize?client_id=..y.co' (redirected from 'https://www.bureaucrazy.co/auth/login?_rsc=tgark') from origin 'https://www.bureaucrazy.co' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Failed to load resource: net::ERR_FAILED
1255-f206d8cb7c37a3ff.js:1 Failed to fetch RSC payload for https://www.bureaucrazy.co/auth/login. Falling back to browser navigation. 

```

I have tried out everything  
I can log in successfully, but I get logged out when I refresh the page or navigate to another dynamic route.

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [September 5, 2025, 9:52pm UTC](https://community.auth0.com/t/a-cors-error-appears-in-the-console/191511/3 "2025-09-05T21:52:36Z")

</div>

Hi @MSK1116

Welcome to the Auth0 Community!

You can check out [this community post](https://community.auth0.com/t/cors-error-with-quarkus-backend-and-nextjs-frontend/170021/3) regarding the CORS error that you are receiving.

As the solution mentions, it happens because the login is being served on a different origin than the one requesting it. In these scenarios, you must include the origin to your **Allowed Web Origins** and include your app’s origin URL in the **Allowed Origins (CORS)** of your application settings.

I would also recommend reading through our documentation about [Configuring Cross-Origin Resource Sharing.](https://auth0.com/docs/get-started/applications/set-up-cors).

Let me know if you have any other questions!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![MSK1116](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/msk1116/32/76466_2.png) [@MSK1116](https://community.auth0.com/u/MSK1116)\
**Post date:** [September 6, 2025, 5:48pm UTC](https://community.auth0.com/t/a-cors-error-appears-in-the-console/191511/4 "2025-09-06T17:48:26Z")

</div>

Thank you, Nik, for your reply!

I indeed have set up both of them

1. 

```auto
Allowed Web Origins=> https://www.bureaucrazy.co

```

2. 

```auto
Allowed origins (CORS)=> https://www.bureaucrazy.co

```

Still, I get the same error on refresh or route change.

Additional info:

```auto
 const session = await auth0.getSession();

```

I’m calling this from the page.jsx

```javascript
//frontend\src\lib\auth0.js
import { Auth0Client } from "@auth0/nextjs-auth0/server";

export const auth0 = new Auth0Client({
  // Options are loaded from environment variables by default
  // Ensure necessary environment variables are properly set

  // domain: process.env.AUTH0_TEN_DOMAIN,
  // clientId: process.env.AUTH0_CLIENT_ID,
  // clientSecret: process.env.AUTH0_CLIENT_SECRET,
  // appBaseUrl: process.env.APP_BASE_URL,
  // secret: process.env.AUTH0_CLIENT_SECRET,

  authorizationParameters: {
    // In v4, the AUTH0_SCOPE and AUTH0_AUDIENCE environment variables are no longer automatically picked up by the SDK.
    // Instead, we need to provide the values explicitly.
    scope: process.env.AUTH0_SCOPE,
    audience: process.env.AUTH0_AUDIENCE,
  },
});

```

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [September 16, 2025, 3:13pm UTC](https://community.auth0.com/t/a-cors-error-appears-in-the-console/191511/5 "2025-09-16T15:13:18Z")

</div>

HI again!

Sorry for the delayed response!

By any chance, are you using any `<Link>` components instead of `<a>` as mentioned in this similar [post](https://community.auth0.com/t/nextjs-cors-no-access-control-allow-origin-header-is-present-on-the-requested-resource/125578/2)?

Also, could you let me know what kind of environment is your application running on? I understand that you are using NextJS, could you let me know what version and if you are using anything else?

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 30, 2025, 3:13pm UTC](https://community.auth0.com/t/a-cors-error-appears-in-the-console/191511/6 "2025-09-30T15:13:26Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
