Skip to content

Commit 80b6ffb

Browse files
authored
Merge branch 'main' into background-function-token
2 parents b9551dd + 0e6dd30 commit 80b6ffb

File tree

181 files changed

+11067
-43284
lines changed

Some content is hidden

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

181 files changed

+11067
-43284
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ module.exports = {
5151
// https://github.com/typescript-eslint/typescript-eslint/issues/2483
5252
'no-shadow': 'off',
5353
'@typescript-eslint/no-shadow': 'error',
54+
'import/max-dependencies': 'off',
5455
},
5556
},
5657
{
57-
files: ['cypress/**/*.spec.ts'],
58+
files: ['cypress/**/*.cy.ts'],
5859
rules: {
5960
'max-nested-callbacks': 0,
6061
'promise/prefer-await-to-then': 0,

.github/workflows/add-to-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
steps:
1010
- name: Generate token
1111
id: generate_token
12-
uses: tibdex/github-app-token@v1.5.2
12+
uses: tibdex/github-app-token@v1.8.0
1313
with:
1414
app_id: ${{ secrets.TOKENS_APP_ID }}
1515
private_key: ${{ secrets.TOKENS_PRIVATE_KEY }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Ensure we add the correct ZenHub label for all new issues
2+
# Avoids problem where checklist issues are not added to the correct ZenHub pipeline
3+
4+
name: Add ZenHub label to issues
5+
on:
6+
issues:
7+
types:
8+
- reopened
9+
- opened
10+
jobs:
11+
label_issues:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
issues: write
15+
steps:
16+
- uses: actions/github-script@v6
17+
with:
18+
script: |
19+
github.rest.issues.addLabels({
20+
issue_number: context.issue.number,
21+
owner: context.repo.owner,
22+
repo: context.repo.repo,
23+
labels: ["Ecosystem: Frameworks"]
24+
})

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
{ prefix: 'security', type: 'security' },
2020
]
2121
steps:
22-
- uses: netlify/pr-labeler-action@v1.0.0
22+
- uses: netlify/pr-labeler-action@v1.1.0
2323
if: startsWith(github.event.pull_request.title, matrix.pr.prefix)
2424
with:
2525
token: '${{ secrets.GITHUB_TOKEN }}'

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.15.1
1+
16.20.1

.release-please-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"packages/runtime": "4.37.1",
3-
"packages/next": "1.4.6"
2+
"packages/runtime": "4.39.1",
3+
"packages/next": "1.4.9"
44
}

cypress/e2e/default/api.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ describe('API routes', () => {
66
})
77
})
88

9+
describe('Dynamic API routes', () => {
10+
it('are bundled correctly', () => {
11+
cy.request('/api/shows/1').then((response) => {
12+
expect(response.status).to.equal(200)
13+
})
14+
})
15+
})
16+
917
describe('Extended API routes', () => {
1018
it('returns HTTP 202 Accepted for background route', () => {
1119
cy.request('POST', 'https://webhook.site/token').then((tokenResponse) => {

cypress/e2e/default/custom-errors.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
describe('Custom error pages', () => {
55
it('should show custom 404 page on /404', () => {
66
cy.visit('/404', {failOnStatusCode: false})
7-
cy.findByText('Custom 404 - Page Not Found')
7+
cy.findByText('Custom 404 - Page Not Found', { selector: 'h1' })
88
})
99

1010
it('should show custom 500 page on /500', () => {
1111
cy.visit('/500', {failOnStatusCode: false})
12-
cy.findByText('Custom 500 - Server-side error occurred')
12+
cy.findByText('Custom 500 - Server-side error occurred', { selector: 'h1' })
1313
})
1414
})

cypress/e2e/default/i18n.cy.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,34 @@ describe('Localization', () => {
3535

3636
cy.findByText('The current locale is en')
3737
})
38+
39+
it(`function handler doesn't produce locale when first language in 'Accept-Language' header is not matching any of locales`, () => {
40+
cy.request({
41+
url: `/`,
42+
followRedirect: false,
43+
headers: {
44+
// jp is not in i18n config, fr is in config
45+
// Netlify Redirects only match on first language
46+
// https://docs.netlify.com/routing/redirects/redirect-options/#redirect-by-country-or-language
47+
// > Language-based redirects always match against the first language reported by the browser in the Accept-Language header regardless of quality value weighting.
48+
// while Next.js matches on every language: https://github.com/vercel/next.js/blob/5d9597879c46b383d595d6f7b37fd373325b7544/test/unit/accept-headers.test.ts
49+
'Accept-Language': 'jp, fr;q=0.9',
50+
// make sure we don't use cached results
51+
cookie: '__prerender_bypass=1',
52+
// above cookie header cause us to hit non-ODB function variant
53+
// below header allow us to force ODB-only code path despite not running ODB (this is just for testing purposes)
54+
'x-next-just-first-accept-language': '1',
55+
},
56+
}).then((response) => {
57+
// make sure we didn't hit SSR handler - not ODB and nothing else handles this request
58+
// once platform starts supporting more languages in Accept-Language header - this test
59+
// will start failing because then we will get platform level redirect
60+
expect(response.headers['x-nf-render-mode']).to.eq('ssr')
61+
62+
// we don't expect for function handler to respond with a redirect
63+
// locale redirects should be handled by Netlify redirects
64+
// otherwise we could wrongly cache locale redirect generated by ODB
65+
expect(response.status).to.eq(200)
66+
})
67+
})
3868
})

cypress/e2e/default/rewrites-redirects.cy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
describe('Rewrites and Redirects', () => {
2-
it('rewrites: points /old to /', () => {
2+
// TODO: detect if rewrite is app or page route for __NEXT_PRIVATE_PREBUNDLED_REACT logic
3+
it.skip('rewrites: points /old to /', () => {
34
// preview mode is off by default
45
cy.visit('/old')
56
cy.findByText('NextJS on Netlify (imported Header component)')
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
describe('Trailing slash enabled', () => {
2-
it('should keep the trailing slash, i.e. points /old/ to /old/', () => {
3-
cy.visit('/old/')
4-
cy.url().should('eq', `${Cypress.config().baseUrl}/old/`)
2+
it('should keep the trailing slash, i.e. points /static/ to /static/', () => {
3+
cy.visit('/static/')
4+
cy.url().should('eq', `${Cypress.config().baseUrl}/static/`)
55
})
66

7-
it('should put a trailing slash when there is none, i.e. points /old to /old/', () => {
8-
cy.visit('/old')
9-
cy.url().should('eq', `${Cypress.config().baseUrl}/old/`)
7+
it('should put a trailing slash when there is none, i.e. points /static to /static/', () => {
8+
cy.visit('/static')
9+
cy.url().should('eq', `${Cypress.config().baseUrl}/static/`)
1010
})
1111
})

cypress/e2e/middleware/enhanced.cy.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
describe('Enhanced middleware', () => {
2-
it('rewrites the response body', () => {
2+
it('rewrites the response body using request.rewrite()', () => {
3+
cy.visit('/request-rewrite')
4+
cy.get('#message').contains('This was static (& escaping test &) but has been transformed in')
5+
cy.contains("This is an ad that isn't shown by default")
6+
})
7+
8+
it('modifies the page props when using request.rewrite()', () => {
9+
cy.visit('/request-rewrite')
10+
cy.get('script#__NEXT_DATA__').then((element) => {
11+
const { props } = JSON.parse(element.text());
12+
expect(props.pageProps.message).to.include('This was static (& escaping test &) but has been transformed in')
13+
})
14+
})
15+
16+
it('passes in headers within request.rewrite()', () => {
17+
cy.request('/request-rewrite').then((response) => {
18+
expect(response.headers).to.have.property('x-rewrite-test', 'hello')
19+
})
20+
})
21+
22+
it('rewrites the response body using request.next()', () => {
323
cy.visit('/static')
424
cy.get('#message').contains('This was static (& escaping test &) but has been transformed in')
525
cy.contains("This is an ad that isn't shown by default")

cypress/e2e/middleware/standard.cy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ describe('Standard middleware', () => {
4545
expect(response.headers).to.have.property('x-foo', 'bar')
4646
})
4747
})
48+
49+
it('preserves locale on rewrites (skipMiddlewareUrlNormalize: true)', () => {
50+
cy.visit('/de-de/locale-preserving-rewrite')
51+
cy.get('div').should('contain', 'Locale: de-DE')
52+
cy.url().should('eq', `${Cypress.config().baseUrl}/de-de/locale-preserving-rewrite`)
53+
})
4854
})
4955

5056
describe('Middleware matchers', () => {

demos/base-path/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"typescript": "^4.6.3"
1515
},
1616
"dependencies": {
17-
"next": "^13.3.0"
17+
"next": "^13.4.1"
1818
},
1919
"scripts": {
2020
"test": "echo \"Error: no test specified\" && exit 1"

demos/canary/netlify.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ command = "next build"
33
publish = ".next"
44
ignore = "if [ $CACHED_COMMIT_REF == $COMMIT_REF ]; then (exit 1); else git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../..; fi;"
55

6+
[build.environment]
7+
NEXT_SPLIT_API_ROUTES = "true"
8+
NEXT_BUNDLE_BASED_ON_NFT_FILES = "true"
9+
610
[[plugins]]
711
package = "@netlify/plugin-nextjs"
812

0 commit comments

Comments
 (0)