Skip to content

Commit

Permalink
Make dev watch ignore more specific (#39504)
Browse files Browse the repository at this point in the history
This fixes the case where we were incorrectly ignoring the next-auth API endpoint since it matched the `.next` watch ignore and also adds a test case to ensure we match this route correctly. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: #39495
  • Loading branch information
ijjk committed Aug 11, 2022
1 parent f863ba7 commit d158c0c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/server/dev/next-dev-server.ts
Expand Up @@ -266,7 +266,7 @@ export default class DevServer extends Server {
})

const wp = (this.webpackWatcher = new Watchpack({
ignored: /(node_modules|\.next)/,
ignored: /([/\\]node_modules[/\\]|[/\\]\.next[/\\]|[/\\]\.git[/\\])/,
}))
const pages = [this.pagesDir]
const app = this.appDir ? [this.appDir] : []
Expand Down
3 changes: 3 additions & 0 deletions test/integration/api-support/pages/api/auth/[...nextauth].js
@@ -0,0 +1,3 @@
export default function handler(req, res) {
res.json({ from: 'auth' })
}
8 changes: 8 additions & 0 deletions test/integration/api-support/test/index.test.js
Expand Up @@ -26,6 +26,14 @@ let mode
let app

function runTests(dev = false) {
it('should respond from /api/auth/[...nextauth] correctly', async () => {
const res = await fetchViaHTTP(appPort, '/api/auth/signin', undefined, {
redirect: 'manual',
})
expect(res.status).toBe(200)
expect(await res.json()).toEqual({ from: 'auth' })
})

it('should handle 204 status correctly', async () => {
const res = await fetchViaHTTP(appPort, '/api/status-204', undefined, {
redirect: 'manual',
Expand Down

0 comments on commit d158c0c

Please sign in to comment.