feat: Upgrade to express 5.0.1 (#9530)
BREAKING CHANGE: This upgrades the internally used Express framework from version 4 to 5, which may be a breaking change. If Parse Server is set up to be mounted on an Express application, we recommend to also use version 5 of the Express framework to avoid any compatibility issues. Note that even if there are no issues after upgrading, future releases of Parse Server may introduce issues if Parse Server internally relies on Express 5-specific features which are unsupported by the Express version on which it is mounted. See the Express [migration guide](https://expressjs.com/en/guide/migrating-5.html) and [release announcement](https://expressjs.com/2024/10/15/v5-release.html#breaking-changes) for more info.
This commit is contained in:
@@ -196,7 +196,7 @@ export async function handleParseHeaders(req, res, next) {
|
||||
info.clientSDK = ClientSDK.fromString(info.clientVersion);
|
||||
}
|
||||
|
||||
if (fileViaJSON) {
|
||||
if (fileViaJSON && req.body) {
|
||||
req.fileData = req.body.fileData;
|
||||
// We need to repopulate req.body with a buffer
|
||||
var base64 = req.body.base64;
|
||||
@@ -450,7 +450,7 @@ export function allowCrossDomain(appId) {
|
||||
}
|
||||
|
||||
export function allowMethodOverride(req, res, next) {
|
||||
if (req.method === 'POST' && req.body._method) {
|
||||
if (req.method === 'POST' && req.body?._method) {
|
||||
req.originalMethod = req.method;
|
||||
req.method = req.body._method;
|
||||
delete req.body._method;
|
||||
@@ -685,3 +685,16 @@ function malformedContext(req, res) {
|
||||
res.status(400);
|
||||
res.json({ code: Parse.Error.INVALID_JSON, error: 'Invalid object for context.' });
|
||||
}
|
||||
|
||||
/**
|
||||
* Express 4 allowed a double forward slash between a route and router. Although
|
||||
* this should be considered an anti-pattern, we need to support it for backwards
|
||||
* compatibility.
|
||||
*
|
||||
* Technically valid URL with double foroward slash:
|
||||
* http://localhost:1337/parse//functions/testFunction
|
||||
*/
|
||||
export function allowDoubleForwardSlash(req, res, next) {
|
||||
req.url = req.url.startsWith('//') ? req.url.substring(1) : req.url;
|
||||
next();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user