Bugfix/fix TransformDataSourceInRequestInterceptor after upgrade to NestJS 11 (#4741)

* Fix TransformDataSourceInRequestInterceptor for Express 5
This commit is contained in:
Thomas Kaul 2025-05-24 15:15:51 +01:00 committed by GitHub
parent a1786c95a1
commit a8a31c141d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,7 +43,16 @@ export class TransformDataSourceInRequestInterceptor<T>
const dataSourceValue = request[type]?.dataSource;
if (dataSourceValue && !DataSource[dataSourceValue]) {
request[type].dataSource = decodeDataSource(dataSourceValue);
// In Express 5, request.query is read-only, so request[type].dataSource cannot be directly modified
Object.defineProperty(request, type, {
configurable: true,
enumerable: true,
value: {
...request[type],
dataSource: decodeDataSource(dataSourceValue)
},
writable: true
});
}
}
}