Skip to content

Commit 76324ab

Browse files
committed
Merge branch 'main' into mk/edge-router
2 parents ae64388 + a5339d2 commit 76324ab

Some content is hidden

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

77 files changed

+8125
-1132
lines changed

.github/workflows/fossa.yml

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,11 @@ on:
66
- main
77
- chore/fossa-workflow # convenience branch for future fossa tweaks
88

9-
defaults:
10-
run:
11-
shell: bash
12-
139
jobs:
14-
fossa:
10+
fossa-scan:
1511
runs-on: ubuntu-latest
1612
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v2
19-
- name: Download fossa cli
20-
run: |-
21-
curl -L https://github.com/fossas/fossa-cli/releases/download/v1.1.2/fossa-cli_1.1.2_linux_amd64.tar.gz > fossa-cli.tar.gz
22-
tar -xvzf fossa-cli.tar.gz
23-
mkdir -p $HOME/.local/bin
24-
echo "$HOME/.local/bin" >> $GITHUB_PATH
25-
mv fossa $HOME/.local/bin/fossa
26-
- name: Fossa init
27-
run: fossa init
28-
- name: Set env
29-
run: echo "line_number=$(grep -n "project" .fossa.yml | cut -f1 -d:)" >> $GITHUB_ENV
30-
- name: Configuration
31-
run: |-
32-
sed -i "${line_number}s|.*| project: git@github.com:${GITHUB_REPOSITORY}.git|" .fossa.yml
33-
cat .fossa.yml
34-
- name: Upload dependencies
35-
run: fossa analyze --debug
36-
env:
37-
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
13+
- uses: actions/checkout@v3
14+
- uses: fossas/fossa-action@main # Use a specific version if locking is preferred
15+
with:
16+
api-key: ${{secrets.FOSSA_API_KEY}}

.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.21.2",
3-
"packages/next": "1.1.1"
2+
"packages/runtime": "4.23.1",
3+
"packages/next": "1.3.0"
44
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"deno.enablePaths": [
33
"packages/runtime/src/templates/edge",
4-
"packages/runtime/src/templates/shared-edge",
4+
"packages/runtime/src/templates/edge-shared",
55
"demos/middleware/.netlify/edge-functions",
66
"demos/custom-routes/.netlify/edge-functions",
77
"demos/server-components/.netlify/edge-functions",
Lines changed: 125 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,127 @@
1+
describe('Static Routing', () => {
2+
it('renders correct page via SSR on a static route', () => {
3+
cy.request('/getServerSideProps/static/').then((res) => {
4+
expect(res.status).to.eq(200)
5+
expect(res.headers).to.have.property('x-render-mode', 'ssr')
6+
expect(res.body).to.contain('Sleepy Hollow')
7+
})
8+
})
9+
it('serves correct static file on a static route', () => {
10+
cy.request('/getStaticProps/static/').then((res) => {
11+
expect(res.status).to.eq(200)
12+
expect(res.headers).to.not.have.property('x-render-mode')
13+
expect(res.body).to.contain('Dancing with the Stars')
14+
})
15+
})
16+
it('renders correct page via ODB on a static route', () => {
17+
cy.request('/getStaticProps/with-revalidate/').then((res) => {
18+
expect(res.status).to.eq(200)
19+
expect(res.headers).to.have.property('x-render-mode', 'isr')
20+
expect(res.body).to.contain('Dancing with the Stars')
21+
})
22+
})
23+
})
24+
125
describe('Dynamic Routing', () => {
2-
it('loads page', () => {
3-
cy.visit('/shows/250')
4-
cy.findByRole('heading').should('contain', '250')
5-
cy.findByText('Kirby Buckets')
26+
it('renders correct page via SSR on a dynamic route', () => {
27+
cy.request('/getServerSideProps/1/').then((res) => {
28+
expect(res.status).to.eq(200)
29+
expect(res.headers).to.have.property('x-render-mode', 'ssr')
30+
expect(res.body).to.contain('Under the Dome')
31+
})
32+
})
33+
it('renders correct page via SSR on a dynamic catch-all route', () => {
34+
cy.request('/getServerSideProps/all/1/').then((res) => {
35+
expect(res.status).to.eq(200)
36+
expect(res.headers).to.have.property('x-render-mode', 'ssr')
37+
expect(res.body).to.contain('Under the Dome')
38+
})
39+
})
40+
it('serves correct static file on a prerendered dynamic route with fallback: false', () => {
41+
cy.request('/getStaticProps/1/').then((res) => {
42+
expect(res.status).to.eq(200)
43+
expect(res.headers).to.not.have.property('x-render-mode')
44+
expect(res.body).to.contain('Under the Dome')
45+
})
46+
})
47+
it('renders custom 404 on a non-prerendered dynamic route with fallback: false', () => {
48+
cy.request({ url: '/getStaticProps/3/', failOnStatusCode: false }).then((res) => {
49+
expect(res.status).to.eq(404)
50+
expect(res.headers).to.have.property('x-render-mode', 'odb')
51+
expect(res.body).to.contain('Custom 404')
52+
})
53+
})
54+
it('serves correct static file on a prerendered dynamic route with fallback: true', () => {
55+
cy.request('/getStaticProps/withFallback/1/').then((res) => {
56+
expect(res.status).to.eq(200)
57+
expect(res.headers).to.not.have.property('x-render-mode')
58+
expect(res.body).to.contain('Under the Dome')
59+
})
60+
})
61+
it('renders fallback page via ODB on a non-prerendered dynamic route with fallback: true', () => {
62+
cy.request('/getStaticProps/withFallback/3/').then((res) => {
63+
expect(res.status).to.eq(200)
64+
// expect 'odb' until https://github.com/netlify/pillar-runtime/issues/438 is fixed
65+
expect(res.headers).to.have.property('x-render-mode', 'odb')
66+
// expect 'Bitten' until the above is fixed and we can test for fallback 'Loading...' message
67+
expect(res.body).to.contain('Bitten')
68+
})
69+
})
70+
it('serves correct static file on a prerendered dynamic route with fallback: blocking', () => {
71+
cy.request('/getStaticProps/withFallbackBlocking/1/').then((res) => {
72+
expect(res.status).to.eq(200)
73+
expect(res.headers).to.not.have.property('x-render-mode')
74+
expect(res.body).to.contain('Under the Dome')
75+
})
76+
})
77+
it('renders correct page via ODB on a non-prerendered dynamic route with fallback: blocking', () => {
78+
cy.request('/getStaticProps/withFallbackBlocking/3/').then((res) => {
79+
expect(res.status).to.eq(200)
80+
expect(res.headers).to.have.property('x-render-mode', 'odb')
81+
expect(res.body).to.contain('Bitten')
82+
})
83+
})
84+
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: false', () => {
85+
cy.request('/getStaticProps/withRevalidate/1/').then((res) => {
86+
expect(res.status).to.eq(200)
87+
expect(res.headers).to.have.property('x-render-mode', 'isr')
88+
expect(res.body).to.contain('Under the Dome')
89+
})
90+
})
91+
it('renders custom 404 on a non-prerendered dynamic route with revalidate and fallback: false', () => {
92+
cy.request({ url: '/getStaticProps/withRevalidate/3/', failOnStatusCode: false }).then((res) => {
93+
expect(res.status).to.eq(404)
94+
expect(res.headers).to.have.property('x-render-mode', 'odb')
95+
expect(res.body).to.contain('Custom 404')
96+
})
97+
})
98+
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: true', () => {
99+
cy.request('/getStaticProps/withRevalidate/withFallback/1/').then((res) => {
100+
expect(res.status).to.eq(200)
101+
expect(res.headers).to.have.property('x-render-mode', 'isr')
102+
expect(res.body).to.contain('Under the Dome')
103+
})
104+
})
105+
it('renders fallback page via ODB on a non-prerendered dynamic route with revalidate and fallback: true', () => {
106+
cy.request('/getStaticProps/withRevalidate/withFallback/3/').then((res) => {
107+
expect(res.status).to.eq(200)
108+
expect(res.headers).to.have.property('x-render-mode', 'isr')
109+
// expect 'Bitten' until https://github.com/netlify/pillar-runtime/issues/438 is fixed
110+
expect(res.body).to.contain('Bitten')
111+
})
112+
})
113+
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: blocking', () => {
114+
cy.request('/getStaticProps/withRevalidate/withFallbackBlocking/1/').then((res) => {
115+
expect(res.status).to.eq(200)
116+
expect(res.headers).to.have.property('x-render-mode', 'isr')
117+
expect(res.body).to.contain('Under the Dome')
118+
})
119+
})
120+
it('renders correct page via ODB on a non-prerendered dynamic route with revalidate and fallback: blocking', () => {
121+
cy.request('/getStaticProps/withRevalidate/withFallbackBlocking/3/').then((res) => {
122+
expect(res.status).to.eq(200)
123+
expect(res.headers).to.have.property('x-render-mode', 'isr')
124+
expect(res.body).to.contain('Bitten')
125+
})
6126
})
7-
})
127+
})

cypress/integration/middleware/standard.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,26 @@ describe('Standard middleware', () => {
2020
})
2121
})
2222
})
23+
24+
describe('Middleware matchers', () => {
25+
it('does not apply "has" matcher when headers are not sent', () => {
26+
cy.request('/conditional').then((response) => {
27+
expect(response.headers).not.to.have.property('x-is-deno', 'true')
28+
expect(response.headers).not.to.have.property('x-modified-edge', 'true')
29+
})
30+
})
31+
32+
it('matches when headers are sent', () => {
33+
cy.request({ url: '/conditional', headers: { 'x-my-header': 'my-value' } }).then((response) => {
34+
expect(response.headers).to.have.property('x-is-deno', 'true')
35+
expect(response.headers).to.have.property('x-modified-edge', 'true')
36+
})
37+
})
38+
39+
it('matches when headers are sent', () => {
40+
cy.request('/_next/data/build-id/static.json').then((response) => {
41+
expect(response.headers).to.have.property('x-is-deno', 'true')
42+
expect(response.headers).to.have.property('x-modified-edge', 'true')
43+
})
44+
})
45+
})

demos/base-path/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"typescript": "^4.6.3"
1414
},
1515
"dependencies": {
16-
"next": "^12.2.0"
16+
"next": "^12.3.0"
1717
},
1818
"scripts": {
1919
"test": "echo \"Error: no test specified\" && exit 1"

demos/canary/middleware.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { NextResponse } from 'next/server'
2+
import type { NextRequest } from 'next/server'
3+
4+
export async function middleware(req: NextRequest) {
5+
const res = NextResponse.rewrite(new URL('/', req.url))
6+
res.headers.set('x-response-header', 'set in middleware')
7+
res.headers.set('x-is-deno', 'Deno' in globalThis ? 'true' : 'false')
8+
return res
9+
}
10+
11+
export const config = {
12+
matcher: ['/foo'],
13+
}

demos/canary/next.config.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@ const nextConfig = {
88
},
99
images: {
1010
formats: ['image/avif', 'image/webp'],
11-
},
12-
experimental: {
13-
images: {
14-
remotePatterns: [
15-
{
16-
protocol: 'https',
17-
hostname: '*.githubusercontent.com',
18-
},
19-
],
20-
},
21-
},
11+
remotePatterns: [
12+
{
13+
protocol: 'https',
14+
hostname: '*.githubusercontent.com',
15+
},
16+
],
17+
}
2218
}
2319

2420
module.exports = nextConfig

0 commit comments

Comments
 (0)