-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid throwing not found error when not login in nextjs pages #494
Conversation
1657f8d
to
c719377
Compare
.../(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/logs/page.tsx
Outdated
Show resolved
Hide resolved
if (!apiKey) { | ||
const result = await getLatitudeApiKey() | ||
const result = await getLatitudeApiKey(workspace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to fetch again workspace when is already fetched by the users of this function. Passing it by argument
@@ -20,12 +18,8 @@ export default async function DashboardLayout({ | |||
}: Readonly<{ | |||
children: ReactNode | |||
}>) { | |||
const data = await getSession() | |||
if (!data.session) return redirect(ROUTES.auth.login) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already happening in the main layout. Is confusing having it here
@@ -26,6 +26,8 @@ export default async function PrivateLayout({ | |||
if (!data.session) return redirect(ROUTES.auth.login) | |||
|
|||
const { workspace, user } = await getCurrentUser() | |||
if (!user) return redirect(ROUTES.auth.login) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without session there is no user. But doesn't hurt this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is why I mentioned to do the check in a middleware as redirects in pages always throw. Nextjs docs actually recommend doing any pre-render redirects in middleware (for the future)
a7d17c9
to
2ad5785
Compare
@@ -44,6 +44,7 @@ export default function WorkspaceApiKeys() { | |||
</TableCell> | |||
<TableCell> | |||
<Tooltip | |||
asChild |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that the default behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think. I had to add it. Not sure if default behaviour makes sense. I don't see recommended on radix docs
https://www.radix-ui.com/primitives/docs/guides/composition#composing-multiple-primitives
Throwing error end in Sentry with a NotFound. What we want to do is redirect user to /login
2ad5785
to
37156d7
Compare
What?
This issue
https://latitude-l5.sentry.io/issues/5964814238/?project=4507922531418112&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D%20error.unhandled%3Atrue&referrer=issue-stream&statsPeriod=14d&stream_index=0