Compare commits
2 commits
55db38f064
...
99ffd5ee8c
| Author | SHA1 | Date | |
|---|---|---|---|
| 99ffd5ee8c | |||
| b6e60c8c0b |
3 changed files with 43 additions and 0 deletions
41
app/api/monitoring/route.ts
Normal file
41
app/api/monitoring/route.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { NextRequest, NextResponse } from 'next/server'
|
||||
|
||||
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN
|
||||
? new URL(process.env.NEXT_PUBLIC_SENTRY_DSN)
|
||||
: null
|
||||
const sentryProjectId = dsn?.pathname.replace('/', '')
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
if (!dsn) {
|
||||
return NextResponse.json({ error: 'Sentry not configured' }, { status: 404 })
|
||||
}
|
||||
|
||||
const envelope = await request.text()
|
||||
const header = envelope.split('\n')[0]
|
||||
|
||||
let envelopeDsn: URL
|
||||
try {
|
||||
envelopeDsn = new URL(JSON.parse(header).dsn)
|
||||
} catch {
|
||||
return NextResponse.json({ error: 'Invalid envelope' }, { status: 400 })
|
||||
}
|
||||
|
||||
if (envelopeDsn.hostname !== dsn.hostname) {
|
||||
return NextResponse.json({ error: 'Invalid host' }, { status: 400 })
|
||||
}
|
||||
|
||||
const projectId = envelopeDsn.pathname.replace('/', '')
|
||||
if (projectId !== sentryProjectId) {
|
||||
return NextResponse.json({ error: 'Invalid project' }, { status: 400 })
|
||||
}
|
||||
|
||||
const upstreamUrl = `https://${dsn.hostname}/api/${sentryProjectId}/envelope/`
|
||||
|
||||
const response = await fetch(upstreamUrl, {
|
||||
method: 'POST',
|
||||
body: envelope,
|
||||
headers: { 'Content-Type': 'application/x-sentry-envelope' },
|
||||
})
|
||||
|
||||
return NextResponse.json({}, { status: response.status })
|
||||
}
|
||||
|
|
@ -131,6 +131,7 @@ export default async function PersonalitiesPage({ searchParams }: PageProps) {
|
|||
<Link
|
||||
key={l}
|
||||
href={`/p?lettre=${l}`}
|
||||
scroll={false}
|
||||
className={`${styles.letterLink} ${lettre === l ? styles.letterActive : ''}`}
|
||||
>
|
||||
{l}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import * as Sentry from '@sentry/nextjs'
|
|||
|
||||
Sentry.init({
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
tunnel: '/api/monitoring',
|
||||
tracesSampleRate: 0.1,
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
replaysSessionSampleRate: 0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue