Worker Routes not working

I'm trying to create an URL shorter using Cloudflare Worker. However, when I try to access the URL, the Worker does not forward to other site, it just display my not found page.
For instance, https://hoaq.id.vn/s/skin will forward to https://drive.google.com/file/d/1BokisPpuP9fQlkaupkdwlUacDQMLDTMy/view?usp=drive_link

Here is the code
export default {
  async fetch(request, env) {
    return await handleRequest(request, env).catch(
      (err) => new Response(err.stack, { status: 500 })
    )
  }
}

async function handleRequest(request, env) {
  const url = new URL(request.url);
  const pathname = url.pathname.substring(2).replace(/^\/|\/$/g, "");
  const location = await env.LINKS.get(pathname);

  if (location) {
    return Response.redirect(location, 301);
  }

  return fetch(request);
}
image.png
Was this page helpful?