export default { async fetch(request) { const links = { "movie": "https://example.com/movie-page", "netflix": "https://example.com/netflix", "telegram": "https://t.me/example", "youtube": "https://youtube.com/@example" }; const url = new URL(request.url); const code = url.pathname.replace("/", ""); // Homepage if (!code) { return new Response(` URL Shortener

URL Shortener

Custom Domain Short Links

Example:

/movie

/netflix

`, { headers: { "content-type": "text/html;charset=UTF-8" } }); } // Redirect if (links[code]) { return Response.redirect(links[code], 302); } // 404 return new Response(` 404

404

Short URL not found

`, { status: 404, headers: { "content-type": "text/html;charset=UTF-8" } }); } }