-
Notifications
You must be signed in to change notification settings - Fork 209
Custom App Hosting Headers for NextJS #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4602ad6
progress
mathu97 50297f5
add an overrides file to explicitely override nextjs defaults for app…
mathu97 5df4372
move adapterMetadata to common func
mathu97 2c7a1ca
check for middleware usage and add header
mathu97 62a71db
look at middleware manifest to check if middleware exists
mathu97 3662682
fix path
mathu97 b77e40c
fix test
mathu97 8dbf472
fix lint error
mathu97 8ac3016
bump nextjs adapter
mathu97 2e6d383
fix next app version test
mathu97 8b5b018
update package-lock
mathu97 005b780
update patch version instead of minor
mathu97 e2d7cc5
replace .eslintrc.json with eslint.config.mjs (preferred for next 15)
mathu97 e16ed40
move from using .eslintrc.json to eslint.config.mjs (preferred for ne…
mathu97 b14ccb4
fix e2e test
mathu97 01bf2b7
attempt2
mathu97 1387bc9
fix local test
mathu97 f0d7595
Merge branch 'bug/fix-nextjs-adapter-functional-tests' into feat/cust…
mathu97 23a5efc
add unit tests and e2e tests to test route overrides
mathu97 461b27a
add jsdocs
mathu97 f88c546
Merge remote-tracking branch 'origin/main' into feat/custom-apphostin…
mathu97 f4b045d
add jsdoc for interfaces
mathu97 c658e2c
address comments
mathu97 852da0d
refactor e2e scaffolding to be able to setup nextjs apps to test diff…
mathu97 564fc58
fix e2e tests failing for older node versions
mathu97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
43 changes: 43 additions & 0 deletions
43
packages/@apphosting/adapter-nextjs/e2e/middleware.spec.ts
This file contains hidden or 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,43 @@ | ||
| import * as assert from "assert"; | ||
| import { posix } from "path"; | ||
| import fsExtra from "fs-extra"; | ||
|
|
||
| export const host = process.env.HOST; | ||
| if (!host) { | ||
| throw new Error("HOST environment variable expected"); | ||
| } | ||
|
|
||
| let adapterVersion: string; | ||
| before(() => { | ||
| const packageJson = fsExtra.readJSONSync("package.json"); | ||
| adapterVersion = packageJson.version; | ||
| if (!adapterVersion) throw new Error("couldn't parse package.json version"); | ||
| }); | ||
|
|
||
| describe("middleware", () => { | ||
| it("should have x-fah-adapter header and x-fah-middleware header on all routes", async () => { | ||
| const routes = [ | ||
| "/", | ||
| "/ssg", | ||
| "/ssr", | ||
| "/ssr/streaming", | ||
| "/isr/time", | ||
| "/isr/demand", | ||
| "/nonexistent-route", | ||
| ]; | ||
|
|
||
| for (const route of routes) { | ||
| const response = await fetch(posix.join(host, route)); | ||
| assert.equal( | ||
| response.headers.get("x-fah-adapter"), | ||
| `nextjs-${adapterVersion}`, | ||
| `Route ${route} missing x-fah-adapter header`, | ||
| ); | ||
| assert.equal( | ||
| response.headers.get("x-fah-middleware"), | ||
| "true", | ||
| `Route ${route} missing x-fah-middleware header`, | ||
| ); | ||
| } | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.