Skip to content
Merged
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
12 changes: 5 additions & 7 deletions app/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { headers } from 'next/headers'
import { notFound } from 'next/navigation'
import { SiteFrame } from '@/components/site/SiteFrame'
import { PasteView } from '@/components/PasteView'
import { PasswordPrompt } from '@/components/PasswordPrompt'
Expand All @@ -25,14 +26,11 @@ interface PageProps {
export default async function PastePage({ params }: PageProps) {
const { id } = await params

// An unknown ID answers 404 through app/not-found.tsx, which shows the same
// panel. Rendering the panel here answered 200, so /robots.txt and every
// mistyped link looked like a real page ("Paste robots.txt") to a crawler.
const row = await getPasteRow(id)
if (!row) {
return (
<Page>
<StatusPanel variant="notFound" />
</Page>
)
}
if (!row) notFound()

if (isPasteExpired(row)) {
return (
Expand Down
12 changes: 12 additions & 0 deletions app/robots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { MetadataRoute } from 'next'

/**
* robots.txt. Without this file `/robots.txt` fell through to the `[id]`
* route and came back as a paste page. Raw text and downloads are the same
* content as the paste page in another form, and the API is not for crawlers.
*/
export default function robots(): MetadataRoute.Robots {
return {
rules: [{ userAgent: '*', allow: '/', disallow: ['/api/', '/raw/', '/dl/'] }],
}
}