Skip to content

Commit

Permalink
Update docs for basePath custom-routes interop (vercel#15140)
Browse files Browse the repository at this point in the history
Follow-up to vercel#15041 this updates the documentation for custom-routes to mention `basePath` handling with them
  • Loading branch information
ijjk authored Jul 14, 2020
1 parent 583d1a0 commit 3a9cb2c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/api-reference/next.config.js/headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,37 @@ module.exports = {
},
}
```

### Headers with basePath support

When leveraging [`basePath` support](/docs/api-reference/next.config.js/basepath.md) with headers each `source` is automatically prefixed with the `basePath` unless you add `basePath: false` to the header:

```js
module.exports = {
basePath: '/docs',

async headers() {
return [
{
source: '/with-basePath', // becomes /docs/with-basePath
headers: [
{
key: 'x-hello',
value: 'world'
}
]
},
{
source: '/without-basePath', // is not modified since basePath: false is set
headers: [
{
key: 'x-hello',
value: 'world'
}
]
basePath: false
},
]
},
}
```
27 changes: 27 additions & 0 deletions docs/api-reference/next.config.js/redirects.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,30 @@ module.exports = {
},
}
```

### Redirects with basePath support

When leveraging [`basePath` support](/docs/api-reference/next.config.js/basepath.md) with redirects each `source` and `destination` is automatically prefixed with the `basePath` unless you add `basePath: false` to the redirect:

```js
module.exports = {
basePath: '/docs',

async redirects() {
return [
{
source: '/with-basePath', // automatically becomes /docs/with-basePath
destination: '/another', // automatically becomes /docs/another
permanent: false,
},
{
// does not add /docs since basePath: false is set
source: '/without-basePath',
destination: '/another',
basePath: false,
permanent: false,
},
]
},
}
```
25 changes: 25 additions & 0 deletions docs/api-reference/next.config.js/rewrites.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,28 @@ module.exports = {
},
}
```

### Rewrites with basePath support

When leveraging [`basePath` support](/docs/api-reference/next.config.js/basepath.md) with rewrites each `source` and `destination` is automatically prefixed with the `basePath` unless you add `basePath: false` to the rewrite:

```js
module.exports = {
basePath: '/docs',

async rewrites() {
return [
{
source: '/with-basePath', // automatically becomes /docs/with-basePath
destination: '/another', // automatically becomes /docs/another
},
{
// does not add /docs since basePath: false is set
source: '/without-basePath',
destination: '/another',
basePath: false,
},
]
},
}
```

0 comments on commit 3a9cb2c

Please sign in to comment.