-
Notifications
You must be signed in to change notification settings - Fork 26k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw an error when
target: 'serverless'
is used with Middleware (#…
…37819) Serverless target is deprecated, so we don't support it in Middleware as it's a new feature, but we need to have a good error message for that. This commit solves that. ## Related * Fixes #37433 ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md`
- Loading branch information
Showing
6 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/production/middleware-is-not-allowed-when-using-serverless-target/app/middleware.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default (req) => { | ||
console.log(req.url) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/production/middleware-is-not-allowed-when-using-serverless-target/app/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
target: 'serverless', | ||
} |
3 changes: 3 additions & 0 deletions
3
test/production/middleware-is-not-allowed-when-using-serverless-target/app/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Home() { | ||
return <div>Hello</div> | ||
} |
14 changes: 14 additions & 0 deletions
14
test/production/middleware-is-not-allowed-when-using-serverless-target/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { nextBuild } from 'next-test-utils' | ||
import path from 'path' | ||
|
||
describe('Middleware is not allowed when using serverless target', () => { | ||
it('fails to build', async () => { | ||
const { code, stderr } = await nextBuild( | ||
path.resolve(__dirname, './app'), | ||
undefined, | ||
{ ignoreFail: true, stderr: true } | ||
) | ||
expect(code).toEqual(1) | ||
expect(stderr).toContain('MiddlewareInServerlessTargetError') | ||
}) | ||
}) |