forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add nextjs middleware handling (github#19139)
* feat: add nextjs middleware handling split * fix: eslint errors * fix: filter boolean from csp list * fix: feature flag nextjs server start * feat: add prettier rules for ts,tsx files * fix: remove unnecessary async from next middleware * fix: next middleware name * Update tsconfig.json Co-authored-by: James M. Greene <JamesMGreene@github.com> * Update next-env.d.ts Co-authored-by: James M. Greene <JamesMGreene@github.com> * fix: add typescript linting to lint command * add comment for unsafe-eval, update webpack to use eval in development * fix: feature flag typo Co-authored-by: James M. Greene <JamesMGreene@github.com>
- Loading branch information
1 parent
7dc54c5
commit eaddbc5
Showing
16 changed files
with
1,658 additions
and
38 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
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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
{ | ||
"overrides": [ | ||
{ | ||
"files":[ | ||
"**/*.{yml,yaml}" | ||
], | ||
"files": ["**/*.{yml,yaml}"], | ||
"options": { | ||
"singleQuote": true | ||
} | ||
}, | ||
{ | ||
"files": ["**/*.{ts,tsx}"], | ||
"options": { | ||
"semi": false, | ||
"singleQuote": true, | ||
"printWidth": 100, | ||
"jsxBracketSameLine": false, | ||
"arrowParens": "always" | ||
} | ||
} | ||
] | ||
} |
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 @@ | ||
export const ExampleComponent = () => { | ||
return <div>Welcome to Next.JS land!</div> | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"FEATURE_TEST_TRUE": true, | ||
"FEATURE_TEST_FALSE": false, | ||
"FEATURE_NEW_SITETREE": false | ||
"FEATURE_NEW_SITETREE": false, | ||
"FEATURE_NEXTJS": false | ||
} |
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
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,21 @@ | ||
const next = require('next') | ||
|
||
const { NODE_ENV, FEATURE_NEXTJS } = process.env | ||
const isDevelopment = NODE_ENV === 'development' | ||
|
||
let nextHandleRequest | ||
if (FEATURE_NEXTJS) { | ||
const nextApp = next({ dev: isDevelopment }) | ||
nextHandleRequest = nextApp.getRequestHandler() | ||
nextApp.prepare() | ||
} | ||
|
||
module.exports = function renderPageWithNext (req, res, next) { | ||
if (req.path.startsWith('/_next/')) { | ||
return nextHandleRequest(req, res) | ||
} | ||
|
||
next() | ||
} | ||
|
||
module.exports.nextHandleRequest = nextHandleRequest |
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,2 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/types/global" /> |
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,17 @@ | ||
const { productIds } = require('./lib/all-products') | ||
|
||
module.exports = { | ||
i18n: { | ||
locales: ['en', 'ja'], | ||
defaultLocale: 'en' | ||
}, | ||
async rewrites () { | ||
const defaultVersionId = 'free-pro-team@latest' | ||
return productIds.map((productId) => { | ||
return { | ||
source: `/${productId}/:path*`, | ||
destination: `/${defaultVersionId}/${productId}/:path*` | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.