1ef22e6f95
Build pitch-deck / build-push-deploy (push) Successful in 1m39s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 32s
CI / test-python-voice (push) Successful in 32s
CI / test-bqas (push) Successful in 29s
Behind Orca's reverse proxy, request.url resolves to http://127.0.0.1:3000 which causes redirects to go to the internal address instead of the public domain. Use PITCH_BASE_URL (already set in service.toml) as the base. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
24 lines
723 B
TypeScript
24 lines
723 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import pool from '@/lib/db'
|
|
|
|
interface Ctx { params: Promise<{ code: string }> }
|
|
|
|
const BASE_URL = process.env.PITCH_BASE_URL || 'https://pitch.breakpilot.com'
|
|
|
|
export async function GET(request: NextRequest, ctx: Ctx) {
|
|
const { code } = await ctx.params
|
|
|
|
const { rows } = await pool.query(
|
|
`SELECT sl.token FROM pitch_short_links sl
|
|
JOIN pitch_magic_links ml ON ml.token = sl.token
|
|
WHERE sl.short_code = $1 AND ml.expires_at > NOW()`,
|
|
[code.toLowerCase()],
|
|
)
|
|
|
|
if (rows.length === 0) {
|
|
return NextResponse.redirect(`${BASE_URL}/auth?error=invalid`)
|
|
}
|
|
|
|
return NextResponse.redirect(`${BASE_URL}/auth/verify?token=${rows[0].token}`)
|
|
}
|