blob: c4bf74a6610306f474b309c1c9f1f6dc7108f407 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
export const GET = async ({ url }) => {
const response = await fetch(url.searchParams.get('url') as string);
const contentType = response.headers.get('content-type') as string;
if (contentType.includes('application/json')) {
return Response.json(await response.json(), {
headers: { 'Content-Type': 'application/json' }
});
} else if (contentType.includes('text/html') || contentType.includes('text/plain')) {
return new Response(await response.text(), {
headers: { 'Content-Type': contentType }
});
} else {
return new Response(await response.blob(), {
headers: { 'Content-Type': contentType }
});
}
};
|