diff --git a/src/helpers/files.ts b/src/helpers/files.ts index 4e58e7e2d8..a6d21ac56d 100644 --- a/src/helpers/files.ts +++ b/src/helpers/files.ts @@ -60,6 +60,9 @@ export const matchesRewrite = (file: string, rewrites: Rewrites): boolean => { } export const getMiddleware = async (publish: string): Promise> => { + 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 }) diff --git a/src/templates/getHandler.ts b/src/templates/getHandler.ts index 574460804d..2e4121a235 100644 --- a/src/templates/getHandler.ts +++ b/src/templates/getHandler.ts @@ -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