mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 19:02:29 +03:00
Added body parsing to the frontend
ref https://linear.app/tryghost/issue/MOM-73 We need to add body parsing middleware here, so that NestJS has access to it. We also attach the rawBody which is used to validate the HTTP Signatures
This commit is contained in:
parent
60da243d0c
commit
e98f505ae3
@ -22,6 +22,7 @@ const shared = require('../../server/web/shared');
|
||||
const errorHandler = require('@tryghost/mw-error-handler');
|
||||
const mw = require('./middleware');
|
||||
const labs = require('../../shared/labs');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
const STATIC_IMAGE_URL_PREFIX = `/${urlUtils.STATIC_IMAGE_URL_PREFIX}`;
|
||||
const STATIC_MEDIA_URL_PREFIX = `/${constants.STATIC_MEDIA_URL_PREFIX}`;
|
||||
@ -50,6 +51,21 @@ module.exports = function setupSiteApp(routerConfig) {
|
||||
// enable CORS headers (allows admin client to hit front-end when configured on separate URLs)
|
||||
siteApp.use(mw.cors);
|
||||
|
||||
const jsonParser = bodyParser.json({
|
||||
type: ['application/activity+json', 'application/ld+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'],
|
||||
// TODO: The @RawBody decorator in nest isn't working without this atm...
|
||||
verify: function (req, res, buf) {
|
||||
req.rawBody = buf;
|
||||
}
|
||||
});
|
||||
siteApp.use(async function nestBodyParser(req, res, next) {
|
||||
if (labs.isSet('NestPlayground') || labs.isSet('ActivityPub')) {
|
||||
jsonParser(req, res, next);
|
||||
return;
|
||||
}
|
||||
return next();
|
||||
});
|
||||
|
||||
siteApp.use(async function nestApp(req, res, next) {
|
||||
if (labs.isSet('NestPlayground') || labs.isSet('ActivityPub')) {
|
||||
const originalExpressApp = req.app;
|
||||
|
Loading…
Reference in New Issue
Block a user