mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What? - Upgrade development dependency **Express** to the latest version (5.1.0). - Replace direct assignment of `apiReq.query` with `Object.defineProperty` to ensure the property is writable, enumerable, and configurable. ### Why? - To use the most up-to-date and supported version of Express instead of a legacy one. - To fix [expressjs/express#6633](https://github.com/expressjs/express/issues/6633), where Express 5.x defines `req.query` as a read-only getter, preventing Next.js from overriding it directly. ### How? - Update the Express version in `package.json` and run `pnpm install` to apply the change. - Replace: ```js apiReq.query = query; ``` With ```js Object.defineProperty(apiReq, 'query', { value: { ...query }, writable: true, enumerable: true, configurable: true, }); ``` --------- Co-authored-by: Alessandro Grosselle <[email protected]> Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Co-authored-by: Sebastian Beltran <[email protected]> Co-authored-by: Tim Neutkens <[email protected]>
32 lines
824 B
TypeScript
32 lines
824 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('api-resolver-query-writeable', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
skipDeployment: true,
|
|
startCommand: 'node server.js',
|
|
serverReadyPattern: /Next mode: (production|development)/,
|
|
dependencies: {
|
|
'get-port': '5.1.1',
|
|
express: '5.1.0',
|
|
},
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
it('should allow req.query to be writable and reflect changes made in the API handler', async () => {
|
|
const res = await next.fetch('/api?hello=yes', {
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=utf-8',
|
|
},
|
|
})
|
|
if (!res.ok) {
|
|
throw new Error('Fetch failed')
|
|
}
|
|
const data = await res.json()
|
|
expect(data).toEqual({ query: { hello: 'yes', changed: 'yes' } })
|
|
})
|
|
})
|