Skip to content

Commit

Permalink
fix(board): log on server if prefetched header is not present (#1683)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilielr authored Oct 18, 2024
1 parent f2e0c20 commit 5855baf
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tavla/pages/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import { getBackendUrl } from 'utils/index'
import Head from 'next/head'
import { useEffect } from 'react'
import { logger } from 'utils/logger'
import { IncomingMessage } from 'http'

const log = logger.child({ module: 'board' })
export async function getServerSideProps({
params,
req,
}: {
params: { id: string }
req: IncomingMessage
}) {
const { id } = params

Expand All @@ -27,10 +30,20 @@ export async function getServerSideProps({
notFound: true,
}
}

const organization = await getOrganizationWithBoard(id)

if (!req.headers['next-router-prefetch']) {
log.info({
boardID: board.id,
organization: organization?.name,
})
}

return {
props: {
board,
organization: await getOrganizationWithBoard(id),
organization,
backend_url: getBackendUrl(),
},
}
Expand All @@ -46,10 +59,6 @@ function BoardPage({
backend_url: string
}) {
const updatedBoard = useRefresh(board, backend_url)
log.info({
boardID: board.id,
organization: organization?.name,
})

const title = updatedBoard.meta?.title
? updatedBoard.meta.title + ' | Entur tavla'
Expand Down

0 comments on commit 5855baf

Please sign in to comment.