How to see omitted error in prod
Answered
Harlequin posted this in #help-forum
HarlequinOP
hey in prod i have some error that says it is omitted. Where can i see the full error?
Answered by B33fb0n3
can you change your layout to the following:
import { redirect } from 'next/navigation'
import { getUserServerSide } from '../../../server/utils'
import DashboardLayout from '../../../components/layouts/DashboardLayout'
type Props = {
children: React.ReactNode
}
function Layout(props: Props) {
const { children } = props
const user = await getUserServerSide()
if (!user) return redirect('/login')
return <DashboardLayout user={user}>{children}</DashboardLayout>
}
export default Layout17 Replies
@Harlequin hey in prod i have some error that says it is omitted. Where can i see the full error?
check the serverside logs. If you hosting on vercel check the
Logs tabHarlequinOP
it says it was omitted due to security
@Harlequin it says it was omitted due to security
Share the err pls
HarlequinOP
[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
digest: 'DYNAMIC_SERVER_USAGE',
page: '/dashboard'
}
digest: 'DYNAMIC_SERVER_USAGE',
page: '/dashboard'
}
@Harlequin [Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
digest: 'DYNAMIC_SERVER_USAGE',
page: '/dashboard'
}
This is the issue: https://nextjs.org/docs/messages/dynamic-server-error
There are also ways to directly fix it. Let me know if that worked for you
There are also ways to directly fix it. Let me know if that worked for you
HarlequinOP
still happening:
my layout
utils:
my layout
import { redirect } from 'next/navigation'
import { getUserServerSide } from '../../../server/utils'
import DashboardLayout from '../../../components/layouts/DashboardLayout'
type Props = {
children: React.ReactNode
}
async function layout(props: Props) {
const { children } = props
const user = await getUserServerSide()
if (!user) return redirect('/login')
return <DashboardLayout user={user}>{children}</DashboardLayout>
}
export default layoututils:
'use server'
import { headers as getHeaders } from 'next/headers.js'
import { getPayload } from 'payload'
import configPromise from '@payload-config'
export async function getUserServerSide() {
const headers = getHeaders()
const payload = await getPayload({ config: configPromise })
const { user } = await payload.auth({ headers })
return user
}@B33fb0n3
can you change your layout to the following:
import { redirect } from 'next/navigation'
import { getUserServerSide } from '../../../server/utils'
import DashboardLayout from '../../../components/layouts/DashboardLayout'
type Props = {
children: React.ReactNode
}
function Layout(props: Props) {
const { children } = props
const user = await getUserServerSide()
if (!user) return redirect('/login')
return <DashboardLayout user={user}>{children}</DashboardLayout>
}
export default LayoutAnswer
HarlequinOP
but i need to make it async , right?
So just naming is different
@Harlequin but i need to make it async , right?
try it without async. If you need to remove your methods for just this test, then remove your functions for this test. If it's working after that, I tell you how to add your functions
HarlequinOP
yeah worked, how does it work with my async functions then? and what is the exact issue @B33fb0n3
@Harlequin yeah worked, how does it work with my async functions then? and what is the exact issue <@301376057326567425>
Now create a component that fetches the stuff (and will be async) and then pass it (if needed) to the correct components. That might be a bit complicated, but that's to ensure fast loading pages and remove blank pages while loading
@Harlequin do u need anything else?
@Harlequin ?
HarlequinOP
no thanks!
Great, happy to help. Please mark solution