mirror of https://github.com/sveltejs/svelte
parent
e9d7b9dd57
commit
472e38ddaf
@ -1,14 +1,15 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
const local_svelte_path = env.LOCAL_SVELTE_PATH || '../../../svelte';
|
||||
|
||||
export function GET({ params: { path } }) {
|
||||
export async function GET({ params: { path } }) {
|
||||
if (import.meta.env.PROD || ('/' + path).includes('/.')) {
|
||||
return new Response(undefined, { status: 403 });
|
||||
}
|
||||
return new Response(readFileSync(join(local_svelte_path, path)), {
|
||||
|
||||
const { readFile } = await import('node:fs/promises');
|
||||
|
||||
return new Response(await readFile(`${local_svelte_path}/${path}`), {
|
||||
headers: { 'Content-Type': 'text/javascript' }
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue