blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js

Home Page:https://Blitzjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

useAuthenticatedBlitzContext doesn not populate next url param on redirect (app router)

florian-klemt opened this issue · comments

What is the problem?

When using useAuthenticatedBlitzContext in the app router, the next url parameter is not set after redirection.

What are detailed steps to reproduce this?

Create /app/my-page.tsx

import { Metadata } from "next";
import { useAuthenticatedBlitzContext } from "src/blitz-server";

export const metadata: Metadata = {
  title: "My Page"
};

export default async function MyPage() {
  await useAuthenticatedBlitzContext({
    redirectTo: "/auth/login"
  });

  return (
    <div>
      My Page
    </div>
  );
}

and open http://localhost:3000/my-page (while NOT being authenticated).

You will see that you do get redirected to /auth/login but the next url parameter is missing