diff --git a/frontend/utils/ApiClient.js b/frontend/utils/ApiClient.js index 8616b9674..f9d6191f0 100644 --- a/frontend/utils/ApiClient.js +++ b/frontend/utils/ApiClient.js @@ -1,4 +1,5 @@ import _ from 'lodash'; +import { browserHistory } from 'react-router'; import stores from 'stores'; import constants from '../constants'; @@ -57,6 +58,11 @@ class ApiClient { return response; } + // Handle 404 + if (response.status === 404) { + return browserHistory.push('/404'); + } + // Handle 401, log out user if (response.status === 401) { stores.user.logout(); diff --git a/server/api/documents.js b/server/api/documents.js index 0337e8e5c..0cffc7323 100644 --- a/server/api/documents.js +++ b/server/api/documents.js @@ -22,6 +22,8 @@ router.post('documents.info', auth({ require: false }), async (ctx) => { }, }); + if (!document) throw httpErrors.NotFound(); + // Don't expose private documents outside the team if (document.private) { if (!ctx.state.user) throw httpErrors.NotFound(); @@ -39,8 +41,6 @@ router.post('documents.info', auth({ require: false }), async (ctx) => { data: await presentDocument(document), }; } - - if (!document) throw httpErrors.NotFound(); }); router.post('documents.search', auth(), async (ctx) => {