diff --git a/packages/ui/certd-client/index.html b/packages/ui/certd-client/index.html index 3e60def3..7c99ff69 100644 --- a/packages/ui/certd-client/index.html +++ b/packages/ui/certd-client/index.html @@ -2,7 +2,7 @@ - + Loading diff --git a/packages/ui/certd-server/public/index.html b/packages/ui/certd-server/public/index.html index d00491fd..a5a4752f 100644 --- a/packages/ui/certd-server/public/index.html +++ b/packages/ui/certd-server/public/index.html @@ -1 +1 @@ -1 +certd server is ready diff --git a/packages/ui/certd-server/src/config/config.default.ts b/packages/ui/certd-server/src/config/config.default.ts index c096c041..352075c3 100644 --- a/packages/ui/certd-server/src/config/config.default.ts +++ b/packages/ui/certd-server/src/config/config.default.ts @@ -4,7 +4,6 @@ import { MidwayConfig } from '@midwayjs/core'; // import { fileURLToPath } from 'node:url'; // // const __filename = fileURLToPath(import.meta.url); // const __dirname = dirname(fileURLToPath(import.meta.url)); - // eslint-disable-next-line node/no-extraneous-import import { FlywayHistory } from '@certd/midway-flyway-js'; import { UserEntity } from '../modules/sys/authority/entity/user.js'; @@ -15,8 +14,9 @@ import { mergeConfig } from './loader.js'; import { libServerEntities } from '@certd/lib-server'; import { commercialEntities } from '@certd/commercial-core'; import { tmpdir } from 'node:os'; -import { uploadWhiteList, DefaultUploadFileMimeType } from '@midwayjs/upload'; +import { DefaultUploadFileMimeType, uploadWhiteList } from '@midwayjs/upload'; import path from 'path'; + const env = process.env.NODE_ENV || 'development'; const development = { @@ -27,7 +27,7 @@ const development = { staticFile: { usePrecompiledGzip: true, buffer: true, - maxAge: 30 * 24 * 60 * 60 * 1000, + maxAge: 30 * 24 * 60 * 60, gzip: true, dirs: { default: { @@ -35,14 +35,10 @@ const development = { dir: 'public', alias: { '/': '/index.html', + '\\': '/index.html', }, + maxFiles: 200, }, - // '/index.html': { - // maxAge: 0, - // }, - // '/': { - // maxAge: 0, - // }, }, }, cron: { diff --git a/packages/ui/certd-server/src/configuration.ts b/packages/ui/certd-server/src/configuration.ts index 41221fad..c83ef0f4 100644 --- a/packages/ui/certd-server/src/configuration.ts +++ b/packages/ui/certd-server/src/configuration.ts @@ -18,6 +18,7 @@ import * as libServer from '@certd/lib-server'; import * as commercial from '@certd/commercial-core'; import * as upload from '@midwayjs/upload'; import { setLogger } from '@certd/acme-client'; +import { IMidwayKoaContext, NextFunction } from '@midwayjs/koa'; process.on('uncaughtException', error => { console.error('未捕获的异常:', error); // 在这里可以添加日志记录、发送错误通知等操作 @@ -61,6 +62,15 @@ export class MainConfiguration { origin: '*', }) ); + // + // this.app.use(async (ctx, next) => { + // // 只在返回 'index.html' 的时候设置 maxAge + // if (ctx.path === '/') { + // // ctx.response.redirect('/index.html'); + // ctx.send(file) + // return; + // } + // }); // bodyparser options see https://github.com/koajs/bodyparser //this.app.use(bodyParser()); //请求日志打印 @@ -76,6 +86,13 @@ export class MainConfiguration { ResetPasswdMiddleware, ]); + this.app.getMiddleware().insertFirst(async (ctx: IMidwayKoaContext, next: NextFunction) => { + await next(); + if (ctx.path === '/' || ctx.path === '/index.html') { + ctx.response.set('Cache-Control', 'public,max-age=180'); + } + }); + //acme setlogger setLogger((text: string) => { logger.info(text);