-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make sure headers set in middlewares are accessibly by layouts and pa…
…ges (#811) * make sure headers set in middlewares are accessibly by layouts and pages * update tsconfig to include vitest config file
- Loading branch information
1 parent
fe94720
commit 9dd9fe4
Showing
19 changed files
with
5,266 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@cloudflare/next-on-pages': patch | ||
--- | ||
|
||
make sure headers set in middlewares are accessibly by layouts and pages |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { getAssertVisible } from '@features-utils/getAssertVisible'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
describe('issue-797', () => { | ||
test('should pass headers set in the middleware along to layouts and pages', async () => { | ||
const page = await BROWSER.newPage(); | ||
const assertVisible = getAssertVisible(page); | ||
const pageUrl = `${DEPLOYMENT_URL}/`; | ||
await page.goto(pageUrl); | ||
const html = await assertVisible('html'); | ||
|
||
const layoutAttrHeaderFromMiddleware = await html.getAttribute( | ||
'layout-attr-header-from-middleware', | ||
); | ||
|
||
expect(layoutAttrHeaderFromMiddleware).toEqual( | ||
'this is a header set by the middleware!', | ||
); | ||
|
||
const gottenReqHeaderP = await assertVisible( | ||
'p[data-test-id="header-from-middleware"]', | ||
); | ||
expect(await gottenReqHeaderP.innerText()).toEqual( | ||
'header from middleware: this is a header set by the middleware!', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"setup": "node --loader tsm setup.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// no setup required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
.wrangler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Generated by Wrangler | ||
// by running `wrangler types --env-interface CloudflareEnv env.d.ts` | ||
|
||
interface CloudflareEnv {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"features": [ | ||
"issue797" | ||
], | ||
"buildConfig": { | ||
"buildCommand": "npx --force ../../../packages/next-on-pages", | ||
"buildOutputDirectory": ".vercel/output/static" | ||
}, | ||
"deploymentConfig": { | ||
"compatibilityFlags": ["nodejs_compat"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev'; | ||
|
||
// Here we use the @cloudflare/next-on-pages next-dev module to allow us to use bindings during local development | ||
// (when running the application with `next dev`), for more information see: | ||
// https://github.com/cloudflare/next-on-pages/blob/5712c57ea7/internal-packages/next-dev/README.md | ||
if (process.env.NODE_ENV === 'development') { | ||
await setupDevPlatform(); | ||
} | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
|
||
export default nextConfig; |
Oops, something went wrong.