Are there special rules around redirects to other ...
# functions
l
Are there special rules around redirects to other domains? Nothing happens when the redirect is called? This is a middleware.
Copy code
ts
const exampleShortenedUrls: ShortenedUrl[] = [
    { id: '2tg9xy3', url: 'https://example.com' },
    { id: '3f2tqv', url: 'https://en.wikipedia.org/wiki/Example.com' },
    { id: '48difn', url: 'www.google.com' },
];

...

    const { pathname } = new URL(request.url);
    const id = new URL(request.url).pathname.startsWith('/')
        ? pathname.slice(1)
        : pathname;

    const matchedUrl = exampleShortenedUrls.find((entry) => entry.id === id);

    if (!matchedUrl) {
        console.warn('Unable to find shortened URL', id);
    } else {
        console.info('Found shortened URL and redirecting user', id);
        Response.redirect(matchedUrl.url, 302);  // this does nothing?
    }

    return next();
Copy code
"logs": [
    {
      "message": [
        "Found shortened URL and redirecting user",
        "2tg9xy3"
      ],
      "level": "info",
      "timestamp": 1685119189434
    }
  ],