9 lines
812 B
TypeScript
9 lines
812 B
TypeScript
export async function GET(request:Request,{params}:{params:Promise<{id:string}>}){
|
|
const {id}=await params,file=new URL(request.url).searchParams.get('file')??'manifest.json';
|
|
try{const response=await fetch('http://localhost:3000/rk2/backups/'+encodeURIComponent(id)+'/file?file='+encodeURIComponent(file),{cache:'no-store'});
|
|
if(!response.ok)return new Response('Sicherungsdatei nicht verfügbar',{status:response.status});
|
|
const filename=file.split('/').pop()?.replace(/[^A-Za-z0-9_.-]/g,'_')??'backup.json';
|
|
return new Response(response.body,{headers:{'Content-Type':response.headers.get('Content-Type')??'application/json','Content-Disposition':'attachment; filename="'+filename+'"','Cache-Control':'no-store'}});
|
|
}catch{return new Response('Keine Verbindung zum Backend',{status:502});}
|
|
}
|