Skip to content

Commit

Permalink
fix: #11426, proper v3 style error on maintenance mode [breaking]
Browse files Browse the repository at this point in the history
The v3-style error only applies to v3 routes. Existing Read API and page routes are unaffected.
  • Loading branch information
julianlam committed Apr 14, 2023
1 parent 84dc3ba commit 2615c1e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/middleware/maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const meta = require('../meta');
const user = require('../user');
const groups = require('../groups');
const helpers = require('./helpers');
const controllerHelpers = require('../controllers/helpers');

module.exports = function (middleware) {
middleware.maintenanceMode = helpers.try(async (req, res, next) => {
Expand All @@ -30,6 +31,10 @@ module.exports = function (middleware) {
return next();
}

if (req.originalUrl.startsWith(`${nconf.get('relative_path')}/api/v3/`)) {
return controllerHelpers.formatApiResponse(meta.config.maintenanceModeStatus, res);
}

res.status(meta.config.maintenanceModeStatus);

const data = {
Expand Down

0 comments on commit 2615c1e

Please sign in to comment.