fix: admin route not mounting on production serve (#3071)

This commit is contained in:
Jarrod Flesch
2023-07-25 10:16:55 -04:00
committed by GitHub
parent 242dac5b8e
commit e71866856f
2 changed files with 2 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ const router = express.Router();
type ServeAdminType = (options: { payload: Payload }) => Promise<PayloadHandler>;
export const serveAdmin: ServeAdminType = async ({ payload }) => {
router.use(payload.config.routes.admin, history());
router.use(history());
router.get('*', (req, res, next) => {
if (req.path.substr(-1) === '/' && req.path.length > 1) {

View File

@@ -3,7 +3,7 @@ import { Payload } from '../payload';
async function initAdmin(ctx: Payload): Promise<void> {
if (!ctx.config.admin.disable) {
if (process.env.NODE_ENV === 'production') {
ctx.express.use(await ctx.config.admin.bundler.serve(ctx));
ctx.express.use(ctx.config.routes.admin, await ctx.config.admin.bundler.serve(ctx));
} else {
ctx.express.use(await ctx.config.admin.bundler.dev(ctx));
}