Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecated JSDoc comments for the previous middleware signature #35448

Merged
18 changes: 17 additions & 1 deletion packages/next/server/web/spec-extension/fetch-event.ts
Expand Up @@ -10,13 +10,29 @@ export class NextFetchEvent extends FetchEvent {
this.sourcePage = params.page
}

// @ts-ignore
/**
* @deprecated The `request` is now the first parameter and the API is now async.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/
get request() {
throw new DeprecationError({
page: this.sourcePage,
})
}

/**
* @deprecated `respondWith` is no longer needed and the API is now async
* with the form:
*
* ```ts
lfades marked this conversation as resolved.
Show resolved Hide resolved
* export function middleware(request, event) {
* return new Response("Hello " + request.url)
* }
* ```
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/
respondWith() {
throw new DeprecationError({
page: this.sourcePage,
Expand Down