Skip to content

Commit

Permalink
chore: add ip debug info
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Apr 1, 2024
1 parent 21954c7 commit a5ade7c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
12 changes: 12 additions & 0 deletions src/app/(app)/api.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { cache } from 'react'

import { attachUAAndRealIp } from '~/lib/attach-ua'
import { getQueryClient } from '~/lib/query-client.server'
import { queries } from '~/queries/definition'

export const fetchAggregationData = cache(async () => {
const queryClient = getQueryClient()
attachUAAndRealIp()

return queryClient.fetchQuery(queries.aggregation.root())
})
11 changes: 1 addition & 10 deletions src/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-console */
import { cache } from 'react'
import { ToastContainer } from 'react-toastify'
import { env, PublicEnvScript } from 'next-runtime-env'
import type { Metadata, Viewport } from 'next'
Expand All @@ -16,15 +15,13 @@ import { Root } from '~/components/layout/root/Root'
import { AccentColorStyleInjector } from '~/components/modules/shared/AccentColorStyleInjector'
import { SearchPanelWithHotKey } from '~/components/modules/shared/SearchFAB'
import { TocAutoScroll } from '~/components/modules/toc/TocAutoScroll'
import { attachUAAndRealIp } from '~/lib/attach-ua'
import { sansFont, serifFont } from '~/lib/fonts'
import { getQueryClient } from '~/lib/query-client.server'
import { AggregationProvider } from '~/providers/root/aggregation-data-provider'
import { AppFeatureProvider } from '~/providers/root/app-feature-provider'
import { queries } from '~/queries/definition'

import { WebAppProviders } from '../../providers/root'
import { Analyze } from './analyze'
import { fetchAggregationData } from './api'

const { version } = PKG

Expand All @@ -44,12 +41,6 @@ export function generateViewport(): Viewport {
}
}

const fetchAggregationData = cache(async () => {
const queryClient = getQueryClient()
attachUAAndRealIp()

return queryClient.fetchQuery(queries.aggregation.root())
})
export const generateMetadata = async (): Promise<Metadata> => {
const fetchedData = await fetchAggregationData()

Expand Down
10 changes: 10 additions & 0 deletions src/components/layout/footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { headers } from 'next/headers'

import { ThemeSwitcher } from '~/components/ui/theme-switcher'
import { REQUEST_GEO, REQUEST_IP } from '~/constants/system'

import { FooterInfo } from './FooterInfo'

export const Footer = () => {
const header = headers()
const geo = header.get(REQUEST_GEO)
const ip = header.get(REQUEST_IP)
return (
<footer
data-private-info={JSON.stringify({
geo,
ip,
})}
data-hide-print
className="relative z-[1] mt-32 border-t border-x-uk-separator-opaque-light bg-accent/5 py-6 text-base-content/80 dark:border-uk-separator-opaque-dark"
>
Expand Down
5 changes: 2 additions & 3 deletions src/components/layout/footer/FooterInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link'
import type { FooterConfig } from './config'

import { fetchAggregationData } from '~/app/(app)/api'
import { IonIosArrowDown } from '~/components/icons/arrow'
import { SubscribeTextButton } from '~/components/modules/subscribe/SubscribeTextButton'
import { FloatPopover } from '~/components/ui/float-popover'
Expand Down Expand Up @@ -39,9 +40,7 @@ export const FooterInfo = () => {
}

const FooterLinkSection = async () => {
const queryClient = getQueryClient()
const data = await queryClient.fetchQuery(queries.aggregation.root())
const { footer } = data.theme
const { footer } = (await fetchAggregationData()).theme
const footerConfig: FooterConfig = footer || {
linkSections: defaultLinkSections,
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (isServerSide) {
const $fetch = createFetch({
defaults: {
timeout: 8000,

headers: globalConfigureHeader,
onRequest(context) {
const token = getToken()
Expand Down

0 comments on commit a5ade7c

Please sign in to comment.