From 5c7ae2c5a77e02680ec95b9d98528dd5c213e38d Mon Sep 17 00:00:00 2001 From: James Henry Date: Tue, 31 Aug 2021 13:02:53 +0400 Subject: [PATCH] fix(nextjs): ensure export works with nextjs v11.1 --- packages/next/plugins/with-nx.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index d5a6988c385cf..a80bab3056245 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -34,6 +34,15 @@ function withNx(nextConfig = {} as WithNxOptions) { nextConfig.target = 'experimental-serverless-trace'; } + /** + * In Next.js 11.1.0 and above, it will throw when running an export if httpAgentOptions is not an object. + * Default value taken from next/server/config-shared.ts: + * https://github.com/vercel/next.js/blob/f6d8a112df76197362b407fc1e0fb6f323dccf39/packages/next/server/config-shared.ts#L189 + */ + nextConfig.httpAgentOptions ??= { + keepAlive: true, + }; + const userWebpack = nextConfig.webpack || ((x) => x); return { ...nextConfig,