Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 40 additions & 20 deletions app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,56 @@
import { revalidateTag } from 'next/cache'
import { NextRequest, NextResponse } from 'next/server'

const REVALIDATE_SECRET = process.env.REVALIDATE_SECRET
import { revalidatePath, revalidateTag } from 'next/cache'

export async function POST(request: NextRequest) {
try {
const requestData = await request.json()
const { tag, secret } = requestData
const body = await request.json()
const { path, tag, secret } = body

// Check for secret if configured
if (REVALIDATE_SECRET && secret !== REVALIDATE_SECRET) {
return NextResponse.json({ message: 'Invalid revalidation token' }, { status: 401 })
if (secret !== process.env.REVALIDATION_SECRET) {
return NextResponse.json({ message: 'Invalid secret' }, { status: 401 })
}

// Verify tag is provided
if (!tag) {
return NextResponse.json({ message: 'Missing tag parameter' }, { status: 400 })
const timestamp = new Date().toISOString()

if (path) {
// Revalidate specific path
revalidatePath(path)
console.log(`[ISR] Revalidated path: ${path} at ${timestamp}`)
return NextResponse.json({
message: `Path ${path} revalidated successfully`,
timestamp,
type: 'path'
})
}

// Revalidate the tag
revalidateTag(tag)
if (tag) {
// Revalidate by tag
revalidateTag(tag)
console.log(`[ISR] Revalidated tag: ${tag} at ${timestamp}`)
return NextResponse.json({
message: `Tag ${tag} revalidated successfully`,
timestamp,
type: 'tag'
})
}

return NextResponse.json({
revalidated: true,
message: `Tag "${tag}" revalidated successfully`,
timestamp: Date.now(),
})
return NextResponse.json({ message: 'No path, tag, or type provided' }, { status: 400 })
} catch (error) {
console.error('Revalidation error:', error)
console.error('[ISR] Revalidation error:', error)
return NextResponse.json(
{ message: 'Error processing revalidation request', error: String(error) },
{ message: 'Error revalidating', error: error.message },
{ status: 500 }
)
}
}

// to check revalidation status
export async function GET() {
return NextResponse.json({
message: 'ISR Revalidation API is active',
timestamp: new Date().toISOString(),
endpoints: {
POST: 'Trigger revalidation with { path, tag, secret }'
}
})
}
19 changes: 19 additions & 0 deletions app/docs/(main-docs)/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { notFound } from 'next/navigation'
import DocContent from '@/components/DocContent/DocContent'

export const dynamicParams = false
export const revalidate = 0.5 * 60 * 60 // 30 minutes
export const dynamic = 'force-static'

export async function generateMetadata({
params,
Expand Down Expand Up @@ -62,6 +64,23 @@ export default async function Page({ params }: { params: { slug: string[] } }) {
toc={toc}
hideTableOfContents={hide_table_of_contents || false}
/>
{/* TODO: remove this, debug info */}
{
<div className="cache-debug" style={{
position: 'fixed',
bottom: '10px',
right: '10px',
background: 'rgba(0,0,0,0.8)',
color: 'white',
padding: '10px',
fontSize: '12px',
borderRadius: '4px'
}}>
<div>export revalidate: {revalidate}</div>
<div>Slug: {slug}</div>
<div>Generated: {new Date().toISOString()}</div>
</div>
}
</div>
)
}
2 changes: 1 addition & 1 deletion data/siteMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const siteMetadata = {
description:
'SigNoz is an open-source observability tool powered by OpenTelemetry. Get APM, logs, traces, metrics, exceptions, & alerts in a single tool.',
language: 'en-us',
theme: 'dark', // system, dark or light
theme: 'dark',
siteUrl: 'https://signoz.io',
siteRepo: 'https://github.com/signoz/',
siteLogo: '/img/logo.svg',
Expand Down