@netlify/plugin-nextjs 4.23.0 → 4.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -118,7 +118,7 @@ const writeEdgeFunctions = async (netlifyConfig) => {
118
118
  path: '/_next/image*',
119
119
  });
120
120
  }
121
- if (!process.env.NEXT_DISABLE_NETLIFY_EDGE) {
121
+ if (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1') {
122
122
  const middlewareManifest = await (0, exports.loadMiddlewareManifest)(netlifyConfig);
123
123
  if (!middlewareManifest) {
124
124
  console.error("Couldn't find the middleware manifest");
@@ -54,7 +54,7 @@ const matchesRewrite = (file, rewrites) => {
54
54
  exports.matchesRewrite = matchesRewrite;
55
55
  const getMiddleware = async (publish) => {
56
56
  var _a;
57
- if (!process.env.NEXT_DISABLE_NETLIFY_EDGE) {
57
+ if (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1') {
58
58
  return [];
59
59
  }
60
60
  const manifestPath = (0, pathe_1.join)(publish, 'server', 'middleware-manifest.json');
@@ -282,19 +282,19 @@ const baseServerReplacements = [
282
282
  const nextServerReplacements = [
283
283
  [
284
284
  `getMiddlewareManifest() {\n if (this.minimalMode) return null;`,
285
- `getMiddlewareManifest() {\n if (this.minimalMode || !process.env.NEXT_DISABLE_NETLIFY_EDGE) return null;`,
285
+ `getMiddlewareManifest() {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return null;`,
286
286
  ],
287
287
  [
288
288
  `generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode) return []`,
289
- `generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode || !process.env.NEXT_DISABLE_NETLIFY_EDGE) return [];`,
289
+ `generateCatchAllMiddlewareRoute(devReady) {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return [];`,
290
290
  ],
291
291
  [
292
292
  `generateCatchAllMiddlewareRoute() {\n if (this.minimalMode) return undefined;`,
293
- `generateCatchAllMiddlewareRoute() {\n if (this.minimalMode || !process.env.NEXT_DISABLE_NETLIFY_EDGE) return undefined;`,
293
+ `generateCatchAllMiddlewareRoute() {\n if (this.minimalMode || (process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' && process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1')) return undefined;`,
294
294
  ],
295
295
  [
296
296
  `getMiddlewareManifest() {\n if (this.minimalMode) {`,
297
- `getMiddlewareManifest() {\n if (!this.minimalMode && process.env.NEXT_DISABLE_NETLIFY_EDGE) {`,
297
+ `getMiddlewareManifest() {\n if (!this.minimalMode && (process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1')) {`,
298
298
  ],
299
299
  ];
300
300
  const patchNextFiles = async (root) => {
package/lib/index.js CHANGED
@@ -49,21 +49,21 @@ const plugin = {
49
49
  let usingEdge = false;
50
50
  if ((middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.functions) && Object.keys(middlewareManifest.functions).length !== 0) {
51
51
  usingEdge = true;
52
- if (process.env.NEXT_DISABLE_NETLIFY_EDGE) {
52
+ if (process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1') {
53
53
  failBuild((0, outdent_1.outdent) `
54
54
  You are using Next.js experimental edge runtime, but have set NEXT_DISABLE_NETLIFY_EDGE to true. This is not supported.
55
- To use edge runtime, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`}.
55
+ To use edge runtime, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`} or set it to false.
56
56
  `);
57
57
  }
58
58
  }
59
59
  if ((middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.middleware) && Object.keys(middlewareManifest.middleware).length !== 0) {
60
60
  usingEdge = true;
61
- if (process.env.NEXT_DISABLE_NETLIFY_EDGE) {
61
+ if (process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1') {
62
62
  console.log((0, chalk_1.redBright)((0, outdent_1.outdent) `
63
63
  You are using Next.js Middleware without Netlify Edge Functions.
64
64
  This is deprecated because it negatively affects performance and will disable ISR and static rendering.
65
65
  It also disables advanced middleware features from @netlify/next
66
- To get the best performance and use Netlify Edge Functions, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`}.
66
+ To get the best performance and use Netlify Edge Functions, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`} or set it to false.
67
67
  `));
68
68
  }
69
69
  }
@@ -71,10 +71,17 @@ const plugin = {
71
71
  const config = await (0, config_1.getRequiredServerFiles)(publish);
72
72
  const userDefinedNextAuthUrl = config.config.env.NEXTAUTH_URL;
73
73
  if (userDefinedNextAuthUrl) {
74
- console.log(`NextAuth package detected, NEXTAUTH_URL environment variable set by user to ${userDefinedNextAuthUrl}`);
74
+ console.log(`NextAuth package detected, NEXTAUTH_URL environment variable set by user in next.config.js to ${userDefinedNextAuthUrl}`);
75
+ }
76
+ else if (process.env.NEXTAUTH_URL) {
77
+ // When the value is specified in the netlify.toml or the Netlify UI (will be evaluated in this order)
78
+ const nextAuthUrl = `${process.env.NEXTAUTH_URL}${basePath}`;
79
+ console.log(`NextAuth package detected, NEXTAUTH_URL environment variable set by user in Netlify configuration to ${nextAuthUrl}`);
80
+ config.config.env.NEXTAUTH_URL = nextAuthUrl;
81
+ await (0, config_1.updateRequiredServerFiles)(publish, config);
75
82
  }
76
83
  else {
77
- const nextAuthUrl = `${process.env.URL}${basePath}`;
84
+ const nextAuthUrl = `${process.env.DEPLOY_PRIME_URL}${basePath}`;
78
85
  console.log(`NextAuth package detected, setting NEXTAUTH_URL environment variable to ${nextAuthUrl}`);
79
86
  config.config.env.NEXTAUTH_URL = nextAuthUrl;
80
87
  await (0, config_1.updateRequiredServerFiles)(publish, config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "4.23.0",
3
+ "version": "4.23.2",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -10,7 +10,7 @@
10
10
  "manifest.yml"
11
11
  ],
12
12
  "dependencies": {
13
- "@netlify/esbuild": "0.14.25",
13
+ "@netlify/esbuild": "0.14.39",
14
14
  "@netlify/functions": "^1.2.0",
15
15
  "@netlify/ipx": "^1.2.5",
16
16
  "@vercel/node-bridge": "^2.1.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@delucis/if-env": "^1.1.2",
35
- "@netlify/build": "^27.17.2",
35
+ "@netlify/build": "^27.18.6",
36
36
  "@types/fs-extra": "^9.0.13",
37
37
  "@types/jest": "^27.4.1",
38
38
  "@types/merge-stream": "^1.1.2",