Fix for undefined url param in some pages

This commit is contained in:
yawhn 2022-11-03 02:03:27 +02:00
parent 9bc3f885bc
commit dba4d2240e
1 changed files with 553 additions and 544 deletions

View File

@ -42,6 +42,9 @@ const app = new Koa();
//#region Bull Dashboard
const bullBoardPath = '/queue';
// used as a url param to prevent caching css and images
const nowDateMs = Date.now();
// Authenticate
app.use(async (ctx, next) => {
if (ctx.path === bullBoardPath || ctx.path.startsWith(bullBoardPath + '/')) {
@ -295,6 +298,7 @@ router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => {
icon: meta.iconUrl,
themeColor: meta.themeColor,
privateMode: meta.privateMode,
nowDateMs: nowDateMs,
});
ctx.set('Cache-Control', 'public, max-age=15');
} else {
@ -340,6 +344,7 @@ router.get('/notes/:note', async (ctx, next) => {
icon: meta.iconUrl,
privateMode: meta.privateMode,
themeColor: meta.themeColor,
nowDateMs: nowDateMs,
});
ctx.set('Cache-Control', 'public, max-age=15');
@ -377,6 +382,7 @@ router.get('/@:user/pages/:page', async (ctx, next) => {
icon: meta.iconUrl,
themeColor: meta.themeColor,
privateMode: meta.privateMode,
nowDateMs: nowDateMs,
});
if (['public'].includes(page.visibility)) {
@ -410,6 +416,7 @@ router.get('/clips/:clip', async (ctx, next) => {
privateMode: meta.privateMode,
icon: meta.iconUrl,
themeColor: meta.themeColor,
nowDateMs: nowDateMs,
});
ctx.set('Cache-Control', 'public, max-age=15');
@ -436,6 +443,7 @@ router.get('/gallery/:post', async (ctx, next) => {
icon: meta.iconUrl,
themeColor: meta.themeColor,
privateMode: meta.privateMode,
nowDateMs: nowDateMs,
});
ctx.set('Cache-Control', 'public, max-age=15');
@ -461,6 +469,7 @@ router.get('/channels/:channel', async (ctx, next) => {
icon: meta.iconUrl,
themeColor: meta.themeColor,
privateMode: meta.privateMode,
nowDateMs: nowDateMs,
});
ctx.set('Cache-Control', 'public, max-age=15');
@ -526,7 +535,6 @@ router.get('(.*)', async ctx => {
if (meta.customSplashIcons.length > 0) {
splashIconUrl = meta.customSplashIcons[Math.floor(Math.random() * meta.customSplashIcons.length)];
}
const nowDateMs = Date.now();
await ctx.render('base', {
img: meta.bannerUrl,
title: meta.name || 'Calckey',
@ -546,3 +554,4 @@ router.get('(.*)', async ctx => {
app.use(router.routes());
export default app;