From 3f59ebf986ebb4866b2e0db2d37036367d0e2317 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Mon, 1 Apr 2019 01:05:49 +0900 Subject: [PATCH] =?UTF-8?q?manifest.json=20=E3=81=AB=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=B3=E3=82=B9=E5=90=8D=E3=82=92=E5=8F=8D?= =?UTF-8?q?=E6=98=A0=E3=81=95=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20(#4619)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/web/index.ts | 6 +----- src/server/web/manifest.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 src/server/web/manifest.ts diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 923ae6902..d8525ba11 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -73,11 +73,7 @@ router.get(/^\/sw\.(.+?)\.js$/, async ctx => { }); // Manifest -router.get('/manifest.json', async ctx => { - await send(ctx as any, '/assets/manifest.json', { - root: client - }); -}); +router.get('/manifest.json', require('./manifest')); router.get('/robots.txt', async ctx => { await send(ctx as any, '/assets/robots.txt', { diff --git a/src/server/web/manifest.ts b/src/server/web/manifest.ts new file mode 100644 index 000000000..35d3d1b66 --- /dev/null +++ b/src/server/web/manifest.ts @@ -0,0 +1,16 @@ +import * as Koa from 'koa'; +import * as manifest from '../../client/assets/manifest.json'; +import * as deepcopy from 'deepcopy'; +import fetchMeta from '../../misc/fetch-meta'; + +module.exports = async (ctx: Koa.BaseContext) => { + const json = deepcopy(manifest); + + const instance = await fetchMeta(); + + json.short_name = instance.name || 'Misskey'; + json.name = instance.name || 'Misskey'; + + ctx.set('Cache-Control', 'max-age=300'); + ctx.body = json; +};