add debug mode

This commit is contained in:
Daniel Bulant 2023-08-22 12:11:38 +02:00
parent 8a26a6ae59
commit 2a65e607f2

View file

@ -0,0 +1,17 @@
import { json } from '@sveltejs/kit';
/** @type {import('./$types').RequestHandler} */
export async function GET({ url }) {
console.log("[CORS-DBG] " + url.searchParams.get('url'));
const ret = await fetch(url.searchParams.get('url'));
let text = await ret.text();
let data = text;
try {
data = JSON.parse(text);
} catch (e) {}
return json({
headers: Object.fromEntries(ret.headers.entries()),
body: data
});
}