Add temporary PDF preview links via public token TTL

- Schema: add publicTokenExpiresAt to invoices table
- invoices.generatePublicToken: accepts optional ttlHours param; sets
  expiry timestamp when provided
- invoices.getByPublicToken: returns 403 if token is expired
- New route GET /api/i/[token]/pdf: streams the invoice PDF publicly,
  returns 410 Gone if expired; excluded from auth middleware
- MCP invoices_generate_public_token: exposes ttlHours, returns both
  webUrl (/i/{token}) and pdfUrl (/api/i/{token}/pdf)

https://claude.ai/code/session_014126WHVRT8mftmqkU6dajG
This commit is contained in:
Claude
2026-06-11 05:37:17 +00:00
parent c0a333710f
commit e03c553b7f
5 changed files with 85 additions and 8 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ export function proxy(request: NextRequest) {
const publicRoutes = ["/", "/auth/signin", "/auth/register"];
// Define API routes that should be handled separately
const apiRoutes = ["/api/auth", "/api/trpc", "/api/mcp"];
const apiRoutes = ["/api/auth", "/api/trpc", "/api/mcp", "/api/i"];
// Allow API routes to pass through
if (apiRoutes.some((route) => pathname.startsWith(route))) {