blitz-js / blitz-js/blitz

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

Open
#4,330 0 comments 0 reactions 0 assignees View on GitHub
kind/bug status/triage
Dominant language
TypeScript
Stars
14.1k
Forks
803
PR merge metrics
No merged PRs in 30d

Description

### 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 (


My Page

);
}

```

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

Contributor guide

Open the contributing guide

Research direction

Start with the app-router usage in /app/my-page.tsx and trace useAuthenticatedBlitzContext with redirectTo "/auth/login" while unauthenticated. Reproduce the redirect from /my-page and verify that the resulting login URL includes a next parameter pointing back to /my-page.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.