From fd91a878c144e35157e1d761124f404d4b433af8 Mon Sep 17 00:00:00 2001 From: Kainoa Kanter Date: Thu, 27 Apr 2023 16:25:13 -0700 Subject: [PATCH] Revert "Merge pull request '[feat] Replace Koa-FavICO with a smaller router' (#9853) from daikei/calckey:modularize-favico into develop" This reverts commit 4f6cae76434d927920ae8eac5fad6b72336f29ac, reversing changes made to 64a737d001ca9781ae8bb6995cad69219cba3831. --- packages/backend/package.json | 1 + packages/backend/src/server/web/index.ts | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 888eb9740..157f216b2 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -75,6 +75,7 @@ "koa": "2.13.4", "koa-body": "^6.0.1", "koa-bodyparser": "4.3.0", + "koa-favicon": "2.1.0", "koa-json-body": "5.3.0", "koa-logger": "3.2.1", "koa-mount": "4.0.0", diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 028170cd7..642a17d57 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -8,11 +8,13 @@ import { readFileSync } from "node:fs"; import Koa from "koa"; import Router from "@koa/router"; import send from "koa-send"; +import favicon from "koa-favicon"; import views from "koa-views"; import sharp from "sharp"; import { createBullBoard } from "@bull-board/api"; import { BullAdapter } from "@bull-board/api/bullAdapter.js"; import { KoaAdapter } from "@bull-board/koa"; + import { In, IsNull } from "typeorm"; import { fetchMeta } from "@/misc/fetch-meta.js"; import config from "@/config/index.js"; @@ -96,14 +98,8 @@ app.use( }), ); -// Favicon Router -app.use(async (ctx, next) => { - if (ctx.path != "/favicon.ico") return next(); - const meta = await fetchMeta(); - if (meta.iconUrl === "") - ctx.body = readFileSync(`${_dirname}/../../../assets/favicon.ico`); - else ctx.redirect(meta.iconUrl); -}); +// Serve favicon +app.use(favicon(`${_dirname}/../../../assets/favicon.ico`)); // Common request handler app.use(async (ctx, next) => {