mirror of
https://github.com/4ev-link/4ev.link.git
synced 2026-01-14 00:28:05 +00:00
11 lines
418 B
JavaScript
11 lines
418 B
JavaScript
export async function onRequestGet({ request, params, env, next }) {
|
|
if (['dash', 'api', 'acceptable-use', 'abuse'].includes(params.slug)) return next();
|
|
try {
|
|
const dest = await env.KV_EV.get(params.slug);
|
|
const url = dest ? `https://${dest}` : new URL('/', request.url).href;
|
|
return Response.redirect(url, dest ? 301 : 302);
|
|
} catch (e) {
|
|
return new Response(e.message, { status: 500 });
|
|
}
|
|
}
|