Skip to content

Commit e6bbc07

Browse files
authored
Merge branch 'canary' into cms-builder-io-example
2 parents debb967 + 9f5b61d commit e6bbc07

File tree

205 files changed

+7760
-1908
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+7760
-1908
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
**/.next/**
33
**/_next/**
44
**/dist/**
5+
e2e-tests/**
56
examples/with-typescript-eslint-jest/**
67
examples/with-kea/**
78
packages/next/bundles/webpack/packages/*.runtime.js
@@ -16,4 +17,5 @@ packages/next-codemod/**/*.js
1617
packages/next-codemod/**/*.d.ts
1718
packages/next-env/**/*.d.ts
1819
test/integration/async-modules/**
20+
test/integration/eslint/**
1921
test-timings.json

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Learn how to add code owners here:
22
# https://help.github.com/en/articles/about-code-owners
33

4-
* @timneutkens @Timer @ijjk @lfades @divmain
5-
/docs/ @timneutkens @Timer @ijjk @lfades @divmain @leerob
6-
/examples/ @timneutkens @Timer @ijjk @lfades @divmain @leerob
4+
* @timneutkens @ijjk @lfades @divmain @shuding
5+
/docs/ @timneutkens @ijjk @lfades @divmain @shuding @leerob
6+
/examples/ @timneutkens @ijjk @lfades @divmain @shuding @leerob

.github/pull_request_template.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
Thanks for opening a PR! Your contribution is much appreciated.
3+
In order to make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
4+
Choose the right checklist for the change that you're making:
5+
-->
6+
7+
## Bug
8+
9+
- [ ] Related issues linked using `fixes #number`
10+
- [ ] Integration tests added
11+
12+
## Feature
13+
14+
- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
15+
- [ ] Related issues linked using `fixes #number`
16+
- [ ] Integration tests added
17+
- [ ] Documentation added
18+
- [ ] Telemetry added. In case of a feature if it's used or not.
19+
20+
## Documentation / Examples
21+
22+
- [ ] Make sure the linting passes

contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Our Commitment to Open Source can be found [here](https://vercel.com/oss).
44

55
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
6-
2. Create a new branch `git checkout -b MY_BRANCH_NAME`
6+
2. Create a new branch: `git checkout -b MY_BRANCH_NAME`
77
3. Install yarn: `npm install -g yarn`
88
4. Install the dependencies: `yarn`
99
5. Run `yarn dev` to build and watch for code changes

docs/advanced-features/custom-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ description: Start a Next.js app programmatically using a custom server.
1515
</ul>
1616
</details>
1717

18-
Typically you start your next server with `next start`. It's possible, however, to start a server 100% programmatically in order to use custom route patterns.
18+
By default, Next.js includes its own server with `next start`. If you have an existing backend, you can still use it with Next.js (this is not a custom server). A custom Next.js server allows you to start a server 100% programmatically in order to use custom server patterns. Most of the time, you will not need this – but it's available for complete customization.
1919

2020
> A custom server **can not** be deployed on [Vercel](https://vercel.com/solutions/nextjs), the platform Next.js was made for.
2121

docs/advanced-features/preview-mode.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ description: Next.js has the preview mode for statically generated pages. You ca
1616
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-prismic">Prismic Example</a> (<a href="https://next-blog-prismic.now.sh/">Demo</a>)</li>
1717
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-contentful">Contentful Example</a> (<a href="https://next-blog-contentful.now.sh/">Demo</a>)</li>
1818
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-strapi">Strapi Example</a> (<a href="https://next-blog-strapi.now.sh/">Demo</a>)</li>
19+
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-prepr">Prepr Example</a> (<a href="https://next-blog-prepr.now.sh/">Demo</a>)</li>
1920
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-agilitycms">Agility CMS Example</a> (<a href="https://next-blog-agilitycms.now.sh/">Demo</a>)</li>
2021
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-cosmic">Cosmic Example</a> (<a href="https://next-blog-cosmic.now.sh/">Demo</a>)</li>
2122
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-buttercms">ButterCMS Example</a> (<a href="https://next-blog-buttercms.now.sh/">Demo</a>)</li>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
description: Learn how to opt-in and out of ESLint during development mode and production builds.
3+
---
4+
5+
# ESLint Warnings and Errors
6+
7+
## During builds
8+
9+
Next.js fails your **production build** (`next build`) when ESLint errors are present in your
10+
project.
11+
12+
If you'd like Next.js to dangerously produce production code even when your application has errors,
13+
you can disable ESLint running during the build process.
14+
15+
> It's recommended to run ESLint as part of the production build process to ensure your application
16+
> is resilient against runtime issues.
17+
18+
Open `next.config.js` and disable the `build` option in the `eslint` config:
19+
20+
```js
21+
module.exports = {
22+
eslint: {
23+
// !! WARN !!
24+
// Dangerously allow production builds to successfully complete even if
25+
// your project has ESLint errors.
26+
// !! WARN !!
27+
build: false,
28+
},
29+
}
30+
```
31+
32+
## During development
33+
34+
By default, Next.js does not run ESLint during **development** (`next dev`).
35+
36+
If you would like Next.js to lint files separately in development mode, you can enable it in your
37+
configuration.
38+
39+
> Enabling ESLint during development mode will slow down how fast pages are compiled. Until this is
40+
> optimized, we recommend that you [integrate ESLint in your code
41+
> editor](https://eslint.org/docs/user-guide/integrations#editors).
42+
43+
Open `next.config.js` and enable the `dev` option in the `eslint` config:
44+
45+
```js
46+
module.exports = {
47+
eslint: {
48+
// !! WARN !!
49+
// This can slow down how long pages take to compile during development
50+
// !! WARN !!
51+
dev: true,
52+
},
53+
}
54+
```
55+
56+
## Related
57+
58+
<div class="card">
59+
<a href="/docs/api-reference/next.config.js/introduction.md">
60+
<b>Introduction to next.config.js:</b>
61+
<small>Learn more about the configuration file used by Next.js.</small>
62+
</a>
63+
</div>
64+
65+
<div class="card">
66+
<a href="/docs/basic-features/eslint.md">
67+
<b>ESLint:</b>
68+
<small>Learn more about how to use ESLint in Next.js.</small>
69+
</a>
70+
</div>

docs/api-reference/next.config.js/headers.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,100 @@ module.exports = {
149149
}
150150
```
151151

152+
## Header, Cookie, and Query Matching
153+
154+
To only apply a header when either header, cookie, or query values also match the `has` field can be used. Both the `source` and all `has` items must match for the header to be applied.
155+
156+
`has` items have the following fields:
157+
158+
- `type`: `String` - must be either `header`, `cookie`, `host`, or `query`.
159+
- `key`: `String` - the key from the selected type to match against.
160+
- `value`: `String` or `undefined` - the value to check for, if undefined any value will match. A regex like string can be used to capture a specific part of the value, e.g. if the value `first-(?<paramName>.*)` is used for `first-second` then `second` will be usable in the destination with `:paramName`.
161+
162+
```js
163+
module.exports = {
164+
async headers() {
165+
return [
166+
// if the header `x-add-header` is present,
167+
// the `x-another-header` header will be applied
168+
{
169+
source: '/:path*',
170+
has: [
171+
{
172+
type: 'header',
173+
key: 'x-add-header',
174+
},
175+
],
176+
headers: [
177+
{
178+
key: 'x-another-header',
179+
value: 'hello',
180+
},
181+
],
182+
},
183+
// if the source, query, and cookie are matched,
184+
// the `x-authorized` header will be applied
185+
{
186+
source: '/specific/:path*',
187+
has: [
188+
{
189+
type: 'query',
190+
key: 'page',
191+
value: 'home',
192+
},
193+
{
194+
type: 'cookie',
195+
key: 'authorized',
196+
value: 'true',
197+
},
198+
],
199+
headers: [
200+
{
201+
key: 'x-authorized',
202+
value: ':authorized',
203+
},
204+
],
205+
},
206+
// if the header `x-authorized` is present and
207+
// contains a matching value, the `x-another-header` will be applied
208+
{
209+
source: '/:path*',
210+
has: [
211+
{
212+
type: 'header',
213+
key: 'x-authorized',
214+
value: '(?<authorized>yes|true)',
215+
},
216+
],
217+
headers: [
218+
{
219+
key: 'x-another-header',
220+
value: ':authorized',
221+
},
222+
],
223+
},
224+
// if the host is `example.com`,
225+
// this header will be applied
226+
{
227+
source: '/:path*',
228+
has: [
229+
{
230+
type: 'host',
231+
value: 'example.com',
232+
},
233+
],
234+
headers: [
235+
{
236+
key: 'x-another-header',
237+
value: ':authorized',
238+
},
239+
],
240+
},
241+
]
242+
},
243+
}
244+
```
245+
152246
### Headers with basePath support
153247

154248
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:

docs/api-reference/next.config.js/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = (phase, { defaultConfig }) => {
4444
}
4545
```
4646

47-
The commented lines are the place where you can put the configs allowed by `next.config.js`, which are defined [here](https://github.com/vercel/next.js/blob/canary/packages/next/next-server/server/config.ts#L12-L63).
47+
The commented lines are the place where you can put the configs allowed by `next.config.js`, which are defined [here](https://github.com/vercel/next.js/blob/canary/packages/next/next-server/server/config-shared.ts#L33).
4848

4949
However, none of the configs are required, and it's not necessary to understand what each config does. Instead, search for the features you need to enable or modify in this section and they will show you what to do.
5050

docs/api-reference/next.config.js/redirects.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,83 @@ module.exports = {
9393
}
9494
```
9595

96+
## Header, Cookie, and Query Matching
97+
98+
To only match a redirect when header, cookie, or query values also match the `has` field can be used. Both the `source` and all `has` items must match for the redirect to be applied.
99+
100+
`has` items have the following fields:
101+
102+
- `type`: `String` - must be either `header`, `cookie`, `host`, or `query`.
103+
- `key`: `String` - the key from the selected type to match against.
104+
- `value`: `String` or `undefined` - the value to check for, if undefined any value will match. A regex like string can be used to capture a specific part of the value, e.g. if the value `first-(?<paramName>.*)` is used for `first-second` then `second` will be usable in the destination with `:paramName`.
105+
106+
```js
107+
module.exports = {
108+
async redirects() {
109+
return [
110+
// if the header `x-redirect-me` is present,
111+
// this redirect will be applied
112+
{
113+
source: '/:path*',
114+
has: [
115+
{
116+
type: 'header',
117+
key: 'x-redirect-me',
118+
},
119+
],
120+
permanent: false,
121+
destination: '/another-page',
122+
},
123+
// if the source, query, and cookie are matched,
124+
// this redirect will be applied
125+
{
126+
source: '/specific/:path*',
127+
has: [
128+
{
129+
type: 'query',
130+
key: 'page',
131+
value: 'home',
132+
},
133+
{
134+
type: 'cookie',
135+
key: 'authorized',
136+
value: 'true',
137+
},
138+
],
139+
permanent: false,
140+
destination: '/:path*/:page',
141+
},
142+
// if the header `x-authorized` is present and
143+
// contains a matching value, this redirect will be applied
144+
{
145+
source: '/:path*',
146+
has: [
147+
{
148+
type: 'header',
149+
key: 'x-authorized',
150+
value: '(?<authorized>yes|true)',
151+
},
152+
],
153+
permanent: false,
154+
destination: '/home?authorized=:authorized',
155+
},
156+
// if the host is `example.com`,
157+
// this redirect will be applied
158+
{
159+
source: '/:path*',
160+
has: [
161+
{
162+
type: 'host',
163+
value: 'example.com',
164+
},
165+
],
166+
destination: '/another-page',
167+
},
168+
]
169+
},
170+
}
171+
```
172+
96173
### Redirects with basePath support
97174

98175
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:

0 commit comments

Comments
 (0)