mirror of
https://github.com/velocitatem/cvfs.git
synced 2026-05-31 08:43:37 +00:00
Prepare repository for public deployment
- Replace ReportLab PDF export with LibreOffice headless for proper DOCX formatting preservation - Add libreoffice-writer + fonts-liberation to backend Dockerfile - Proxy public CV PDFs through frontend (/cv/[slug]) instead of redirecting to MinIO storage directly - Fix docker-compose: route backend/worker to internal MinIO URL (http://cvfs-minio:9000), remove MinIO from public network, parameterize all domain/env vars - Add storage cleanup (MinIO artifact deletion) when a document is deleted - Add docker-compose.standalone.yml for self-deployment without Traefik/dokploy - Update .env.example with comprehensive self-deployment documentation https://claude.ai/code/session_017HGM9VPptZG52asT5pbL6Y
This commit is contained in:
@@ -5,32 +5,25 @@ export async function GET(
|
||||
{ params }: { params: Promise<{ slug: string }> }
|
||||
) {
|
||||
const { slug } = await params;
|
||||
|
||||
const backend = process.env.API_BASE_URL ?? "http://localhost:9812";
|
||||
|
||||
const backend = process.env.API_BASE_URL ?? 'http://localhost:9812';
|
||||
|
||||
try {
|
||||
const res = await fetch(`${backend}/api/v1/public/${slug}`, {
|
||||
cache: 'no-store'
|
||||
const res = await fetch(`${backend}/api/v1/public/${encodeURIComponent(slug)}/pdf`, {
|
||||
cache: 'no-store',
|
||||
});
|
||||
|
||||
if (res.status === 404) return new NextResponse('CV not found', { status: 404 });
|
||||
if (!res.ok) return new NextResponse('Failed to fetch CV', { status: res.status });
|
||||
|
||||
const pdf = await res.arrayBuffer();
|
||||
return new NextResponse(pdf, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Disposition': `inline; filename="${slug}.pdf"`,
|
||||
'Cache-Control': 'public, max-age=300',
|
||||
},
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
return new NextResponse('CV not found', { status: 404 });
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
if (!data.asset || !data.asset.artifact_key) {
|
||||
return new NextResponse('CV not found', { status: 404 });
|
||||
}
|
||||
|
||||
// Construct MinIO public URL
|
||||
const storageHost = process.env.MINIO_ENDPOINT || (process.env.NODE_ENV === 'production'
|
||||
? 'https://storage.cv.alves.world'
|
||||
: 'http://localhost:9900');
|
||||
|
||||
const bucket = process.env.MINIO_BUCKET || 'resume-branches';
|
||||
const downloadUrl = `${storageHost}/${bucket}/${data.asset.artifact_key}`;
|
||||
|
||||
return NextResponse.redirect(downloadUrl);
|
||||
} catch (error) {
|
||||
console.error('Error fetching public CV:', error);
|
||||
return new NextResponse('Internal Server Error', { status: 500 });
|
||||
|
||||
Reference in New Issue
Block a user