Skip to content

Commit

Permalink
fix middleware on windows (#30253)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
sokra and kodiakhq[bot] committed Oct 25, 2021
1 parent dfb280b commit 9072e6f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/next/server/dev/next-dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export default class DevServer extends Server {
}

const regexMiddleware = new RegExp(
`/(_middleware.(?:${this.nextConfig.pageExtensions.join('|')}))$`
`[\\\\/](_middleware.(?:${this.nextConfig.pageExtensions.join('|')}))$`
)

const regexPageExtension = new RegExp(
Expand Down Expand Up @@ -249,8 +249,7 @@ export default class DevServer extends Server {

if (regexMiddleware.test(fileName)) {
routedMiddleware.push(
`/${relative(pagesDir!, fileName)}`
.replace(/\\+/g, '')
`/${relative(pagesDir!, fileName).replace(/\\+/g, '/')}`
.replace(/^\/+/g, '/')
.replace(regexMiddleware, '/')
)
Expand Down

0 comments on commit 9072e6f

Please sign in to comment.