Task: Set up a permanent redirect to freecode.academy pages

Set up a permanent redirect to freecode.academy pages

16.06.2026fi1osof.ru

Apparently, at some point before freecode.academy, the content was on fi1osof.ru, and Yandex Webmaster still lists the old pages. We need to set up permanent redirects.

Ворклоги

Done. Commit.

if (
  (statusCode === 404 || ctx.pathname === '/404') &&
  ctx.req?.url &&
  ctx.res
) {
  const res = ctx.res

  const url = `https://freecode.academy${ctx.req.url}`

  const response = await fetch(url).catch(console.error)

  if (response?.ok) {
    res.writeHead(301, {
      Location: url,
    })
    res.end()
  }
}