redirectAuthenticatedTo for authenticated users redirects but doesn't call queries
- Dominant language
- TypeScript
- Stars
- 14.1k
- Forks
- 803
- PR merge metrics
- No merged PRs in 30d
Description
### What is the problem?
When sending users to my app, I always send them to `/auth`, which contains
```ts
LoginPage.redirectAuthenticatedTo = Routes.DashboardPage().pathname;
```
When they get there and the user is logged in, it redirects to `/dashboard` as it should, but the dashboard components never actually calls any of its queries, so the user gets stuck in the suspense fallback component.
### Paste all your error logs here:
```
PASTE_HERE (leave the ``` marks)
```
### Paste all relevant code snippets here:
```tsx
// Login Component
import AuthForm from "app/auth/components/Form";
import { BlitzPage, useRouter } from "blitz";
import React from "react";
const LoginPage: BlitzPage = () => {
const router = useRouter();
return (
{
const next = (router.query.next as string) ?? "/";
router.push(next);
}}
/>
);
};
LoginPage.redirectAuthenticatedTo = "/dashboard";
export default LoginPage;
```
### What are detailed steps to reproduce this?
1. Use code like above (taken from `auth` example) to set up redirectAuthenticatedTo
2. Ensure page redirecting to is a page which includes a `useQuery` and contains a suspense fallback with something like `
3. Visit `/auth` as a logged in user
You will see the fallback component and the page won't load unless refreshed, or another action taken.
### Run `blitz -v` and paste the output here:
```
macOS Big Sur | darwin-x64 | Node: v15.5.1
blitz: 0.30.5 (global)
blitz: 0.38.1 (local)
Package manager: yarn
System:
OS: macOS 11.2.2
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 1.48 GB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.5.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.3.0 - /usr/local/bin/npm
Watchman: Not Found
npmPackages:
@prisma/client: ^2.24.0 => 2.24.0
blitz: 0.38.1 => 0.38.1
prisma: ^2.24.0 => 2.24.0
react: 0.0.0-experimental-3310209d0 => 0.0.0-experimental-3310209d0
react-dom: 0.0.0-experimental-3310209d0 => 0.0.0-experimental-3310209d0
typescript: 4.2.4 => 4.2.4
```
### Please include below any other applicable logs and screenshots that show your problem:
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.