33 lines
970 B
TypeScript
33 lines
970 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export async function GET() {
|
|
const possiblePaths = [
|
|
path.join(process.cwd(), 'public', 'DripZone.apk'),
|
|
'/app/public/DripZone.apk',
|
|
'/home/carlos/apps/dripzone-app/public/DripZone.apk',
|
|
path.join(process.cwd(), 'DripZone.apk'),
|
|
];
|
|
|
|
const apkPath = possiblePaths.find((p) => fs.existsSync(p));
|
|
if (!apkPath) {
|
|
return new NextResponse('APK no disponible en este momento', { status: 404 });
|
|
}
|
|
|
|
const stat = fs.statSync(apkPath);
|
|
const fileBuffer = fs.readFileSync(apkPath);
|
|
|
|
return new NextResponse(fileBuffer, {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/vnd.android.package-archive',
|
|
'Content-Length': stat.size.toString(),
|
|
'Content-Disposition': 'attachment; filename="DripZone.apk"',
|
|
'Cache-Control': 'public, max-age=3600, must-revalidate',
|
|
},
|
|
});
|
|
}
|