Worklog for task "Set up a permanent redirect to freecode.academy pages"

16 июн. 2026 г., 12:38:13

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()
  }
}
16.06.2026