rsnext/test/integration/i18n-support-base-path
Javi Velasco 2d5d43fb75
Refactor server routing (#37725)
This PR fixes an issue where we have a middleware that rewrites every single request to the same origin while having `i18n` configured. It would be something like: 

```typescript
import { NextResponse } from 'next/server'

export function middleware(req) {
  return NextResponse.rewrite(req.nextUrl)
}
```

In this case we are going to be adding always the `locale` at the beginning of the destination since it is a rewrite. This causes static assets to not match and the whole application to break. I believe this is a potential footgun so in this PR we are addressing the issue by removing the locale from pathname for those cases where we check against the filesystem (e.g. public folder).

To achieve this change, this PR introduces some preparation changes and then a refactor of the logic in the server router. After this refactor we are going to be relying on properties that can be defined in the `Route` to decide wether or not we should remove the `basePath`, `locale`, etc instead of checking which _type_ of route it is that we are matching.

Overall this simplifies quite a lot the server router. The way we are testing the mentioned issue is by adding a default rewrite in the rewrite tests middleware.
2022-06-16 21:43:01 +00:00
..
pages test: upgrade playwright-chromium from 1.14.1 to 1.22.2 (#37436) 2022-06-06 23:37:01 -05:00
public/files/texts Refactor server routing (#37725) 2022-06-16 21:43:01 +00:00
test Fix basePath replacing server-side and normalizeLocalePath() when path is empty string (#30978) 2021-11-15 17:33:21 +00:00
next.config.js Fix basePath replacing server-side and normalizeLocalePath() when path is empty string (#30978) 2021-11-15 17:33:21 +00:00