const shortUrl = url.search.substring(1);
const fullUrl = await env.links.get(shortUrl);
if (fullUrl === null) {
- return Response.redirect('https://alu.bz');
+ return new Response('https://alu.bz');
}
- return Response.redirect(fullUrl);
+ return new Response(fullUrl);
}
</main>
<script>
- if (location.pathname !== '' && location.pathname !== '/') {
- fetch(`/api?${location.pathname.substring(1)}`);
- }
+ (async () => {
+ if (location.pathname !== '' && location.pathname !== '/') {
+ location = await fetch(`/api?${location.pathname.substring(1)}`).then(r => r.text());
+ }
+ })();
</script>
<script src="script.js" type="module"></script>
</body>