Next.js Discord

Discord Forum

Auth0 withPageAuthRequired "Request is not Available" in page.jsx

Unanswered
Cinnamon posted this in #help-forum
Open in Discord
CinnamonOP
Does anybody have experience with Auth0? I am trying to wrap my files with withPageAuthRequired but for reason I am getting a Request is not Available message when I feel like I've done what most of the docs have told me.

My main goal is to be able to get user information on the server side as so here: https://developer.auth0.com/resources/guides/web-app/nextjs/basic-authentication#get-server-side-user-profile-information-in-next-js

My app/[lng]/layout.jsx has the <UserProvider> wrapped around the children
const RootLayout = ({ children, params: { lng } }) => {
  return (
    <html lang={lng} dir={dir(lng)}>
      <body>
        <UserProvider>
          <NavBar lng={lng} />
          <BodyFooterWrapper>
            <main className={`${robo.variable} font-sans`}>{children}</main>
            <Footer />
          </BodyFooterWrapper>
        </UserProvider>
      </body>
    </html>
  );
};


My app/[lng]/test/page.jsx crashes with the error message above whenever I go into that page
import { withPageAuthRequired } from "@auth0/nextjs-auth0";

export default withPageAuthRequired(
  function ProtectedPage() {
    return <div>Protected content</div>;
  },
  { returnTo: "/" }
);


And if it helps, client side files are able to call useUser() from auth0. I can go more indepth if needed.

0 Replies