revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s
Local Build and Deploy / deploy (push) Successful in 1m11s
revert style: clean up code with prettier and eslint
This commit is contained in:
1 parent
27de078f54
commit
e85e4d74ea
378 files changed
+20710
-22428
No files matched your search
@@ -1,31 +1,25 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { type NextRequest, NextResponse } from "next/server";
|
||||
import { getFurniAssetDirs } from "@/lib/services/furni-asset-dirs";
|
||||
import { promises as fs } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { getFurniAssetDirs } from '@/lib/services/furni-asset-dirs'
|
||||
|
||||
const CORS_HEADERS = { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, OPTIONS" };
|
||||
const CORS_HEADERS = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, OPTIONS' }
|
||||
|
||||
export async function GET(_request: NextRequest, { params }: { params: Promise<{ path: string[] }> }) {
|
||||
const segments = (await params).path;
|
||||
const filename = segments.at(-1);
|
||||
if (!filename || filename !== path.basename(filename) || !filename.endsWith(".nitro")) {
|
||||
return new NextResponse(null, { status: 404, headers: CORS_HEADERS });
|
||||
const segments = (await params).path
|
||||
const filename = segments.at(-1)
|
||||
if (!filename || filename !== path.basename(filename) || !filename.endsWith('.nitro')) {
|
||||
return new NextResponse(null, { status: 404, headers: CORS_HEADERS })
|
||||
}
|
||||
try {
|
||||
const { nitroDir } = await getFurniAssetDirs();
|
||||
const file = await fs.readFile(path.join(nitroDir, filename));
|
||||
return new NextResponse(file, {
|
||||
headers: {
|
||||
...CORS_HEADERS,
|
||||
"Content-Type": "application/octet-stream",
|
||||
"Cache-Control": "public, max-age=86400, immutable",
|
||||
},
|
||||
});
|
||||
const { nitroDir } = await getFurniAssetDirs()
|
||||
const file = await fs.readFile(path.join(nitroDir, filename))
|
||||
return new NextResponse(file, { headers: { ...CORS_HEADERS, 'Content-Type': 'application/octet-stream', 'Cache-Control': 'public, max-age=86400, immutable' } })
|
||||
} catch {
|
||||
return new NextResponse(null, { status: 404, headers: CORS_HEADERS });
|
||||
return new NextResponse(null, { status: 404, headers: CORS_HEADERS })
|
||||
}
|
||||
}
|
||||
|
||||
export function OPTIONS() {
|
||||
return new NextResponse(null, { status: 204, headers: CORS_HEADERS });
|
||||
return new NextResponse(null, { status: 204, headers: CORS_HEADERS })
|
||||
}
|
||||
Reference in new issue
Block a user