Files
Tim NeutkensandGitHub 20ac9ce9cf Deprecate undocumented custom server methods (#94348)
### What?

Deprecate undocumented custom-server methods exposed by `next()` while
preserving their runtime behavior.

- Add TypeScript deprecation annotations and one-time runtime warnings
for `setAssetPrefix()`, logging helpers, `revalidate()`, and legacy
`render*` helpers.
- Extend custom-server tests to cover warnings and warning
deduplication.
- Move unrelated test fixtures away from deprecated custom-server calls.

### Why?

These methods are not part of the documented custom-server API, but
existing applications may still rely on them. Warning-only deprecation
gives users migration guidance without introducing a breaking runtime
change.

### How?

Warnings are emitted only through `NextCustomServer`, so framework-owned
`NextServer` usage remains quiet. The warning text points `render*`
callers toward `app.getRequestHandler()`, `setAssetPrefix()` callers
toward configuration, and logging and revalidation callers toward
supported application APIs.

The tests retain compatibility assertions for existing behavior, add
deliberate invocations for previously uncovered methods, verify
once-per-process warning deduplication, and remove incidental warning
sources in unrelated fixtures.

<!-- NEXT_JS_LLM_PR -->
2026-06-03 12:23:36 +02:00

28 lines
574 B
JavaScript

const http = require('http')
const next = require('next')
const getPort = require('get-port')
const dev = process.env.NODE_ENV !== 'production'
const dir = __dirname
const app = next({ dev, dir })
const handleNextRequests = app.getRequestHandler()
async function main() {
await app.prepare()
const port = await getPort()
const server = new http.Server((req, res) => {
handleNextRequests(req, res)
})
server.listen(port, () => {
console.log(`- Local: http://localhost:${port}`)
})
}
main().catch((err) => {
console.error(err)
process.exit(1)
})