fix: admin route not mounting on production serve (#3071)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user