diff --git a/server/index.ts b/server/index.ts index f5b41c590f..49e549e765 100644 --- a/server/index.ts +++ b/server/index.ts @@ -6,7 +6,7 @@ import "./logging/tracer"; // must come before importing any instrumented module import http from "http"; import https from "https"; -import Koa from "koa"; +import Koa, { Context } from "koa"; import helmet from "koa-helmet"; import logger from "koa-logger"; import Router from "koa-router"; @@ -90,6 +90,7 @@ async function start(_id: number, disconnect: () => void) { /** Perform a redirect on the browser so that the user's auth cookies are included in the request. */ app.context.redirectOnClient = function ( + this: Context, /** The URL to redirect to */ url: string, /** @@ -113,6 +114,13 @@ async function start(_id: number, disconnect: () => void) { )}" value="${escape(value)}" />`; }); + if (this.userAgent.isBot) { + formFields += ` +
If you are not redirected automatically, please click the button below.
+ + `; + } + this.body = ` @@ -123,7 +131,7 @@ async function start(_id: number, disconnect: () => void) { ${formFields} `; diff --git a/server/routes/index.ts b/server/routes/index.ts index 26fbded27d..81f719b6ee 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -1,10 +1,9 @@ import crypto from "crypto"; import path from "path"; import { formatRFC7231 } from "date-fns"; -import Koa, { BaseContext } from "koa"; +import Koa from "koa"; import Router from "koa-router"; import send from "koa-send"; -import userAgent, { UserAgentContext } from "koa-useragent"; import { languages } from "@shared/i18n"; import { IntegrationType, TeamPreference } from "@shared/types"; import { parseDomain } from "@shared/utils/domains"; @@ -24,8 +23,6 @@ import errors from "./errors"; const koa = new Koa(); const router = new Router(); -koa.use