Skip to content

Commit

Permalink
feat: allow skipping of middleware handling (#1277)
Browse files Browse the repository at this point in the history
* feat: allow skipping of middleware handling

* chore: assign config env to process.env

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
ascorbic and kodiakhq[bot] authored Mar 23, 2022
1 parent 5415f9b commit 63070da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/helpers/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export const matchesRewrite = (file: string, rewrites: Rewrites): boolean => {
}

export const getMiddleware = async (publish: string): Promise<Array<string>> => {
if (process.env.NEXT_SKIP_MIDDLEWARE) {
return []
}
const manifestPath = join(publish, 'server', 'middleware-manifest.json')
if (existsSync(manifestPath)) {
const manifest = await readJson(manifestPath, { throws: false })
Expand Down
4 changes: 3 additions & 1 deletion src/templates/getHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const makeHandler = (conf: NextConfig, app, pageRoot, staticManifest: Array<[str
// This is our flag that we use when patching the source
// eslint-disable-next-line no-underscore-dangle
process.env._BYPASS_SSG = 'true'

for (const [key, value] of Object.entries(conf.env)) {
process.env[key] = String(value)
}
// Set during the request as it needs the host header. Hoisted so we can define the function once
let base: string

Expand Down

0 comments on commit 63070da

Please sign in to comment.