@opennextjs/aws 4.0.1 → 4.0.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.
@@ -5,20 +5,38 @@ import { debug } from "../../logger.js";
5
5
  //#override optimizeImage
6
6
  export async function optimizeImage(headers, imageParams, nextConfig, handleRequest) {
7
7
  const { isAbsolute, href } = imageParams;
8
- // Signature for the fetch Image functions have changed in Next.js 15.5.16 and 16.2.5, so we need to check the version to determine how to call them.
9
- const isAfter1625 = compareSemver(globalThis.nextVersion, ">=", "16.2.5");
10
- const isAfter15516 = compareSemver(globalThis.nextVersion, ">=", "15.5.16") &&
8
+ // Signature for the fetch Image functions have changed across Next.js versions.
9
+ const isV15After15510 = compareSemver(globalThis.nextVersion, ">=", "15.5.10") &&
10
+ compareSemver(globalThis.nextVersion, "<", "16");
11
+ const isV15After15515 = compareSemver(globalThis.nextVersion, ">=", "15.5.16") &&
11
12
  compareSemver(globalThis.nextVersion, "<", "16");
12
- const isNewArgsForInternalFetch = isAfter1625 || isAfter15516;
13
+ const isV16Plus = compareSemver(globalThis.nextVersion, ">=", "16");
14
+ const isAfter1615 = compareSemver(globalThis.nextVersion, ">=", "16.1.5");
15
+ const isAfter1625 = compareSemver(globalThis.nextVersion, ">=", "16.2.5");
16
+ // fetchInternalImage signature varies across Next.js versions:
17
+ // <=v15.5.15, v16.0.0–v16.2.4: fetchInternalImage(href, req, res, handleRequest)
18
+ // v15.5.16–v15.x, v16.2.5+: fetchInternalImage(href, req, res, maximumResponseBody, handleRequest)
19
+ const isNewArgsForInternalFetch = isAfter1625 || isV15After15515;
20
+ // fetchExternalImage signature varies across Next.js versions:
21
+ // <=v15.5.9: fetchExternalImage(href)
22
+ // v15.5.10–v15.x: fetchExternalImage(href, maximumResponseBody)
23
+ // v16.0.0–v16.1.4: fetchExternalImage(href, dangerouslyAllowLocalIP)
24
+ // v16.1.5+: fetchExternalImage(href, dangerouslyAllowLocalIP, maximumResponseBody)
13
25
  // The default value for maximumResponseBody is 50KB in Next code
14
26
  // https://github.com/vercel/next.js/blob/0f38c522/packages/next/src/shared/lib/image-config.ts#L164
15
27
  const maximumResponseBody = nextConfig.images?.maximumResponseBody || 50_000_000;
16
28
  const imageUpstream = isAbsolute
17
29
  ? // https://github.com/vercel/next.js/blob/bfe2ab4/packages/next/src/server/image-optimizer.ts#L711
18
- await (isNewArgsForInternalFetch
30
+ await (isAfter1615
19
31
  ? fetchExternalImage(href, false, maximumResponseBody)
20
- : //@ts-expect-error - fetchExternalImage signature has changed in Next.js 16, it has an extra boolean parameter.
21
- fetchExternalImage(href))
32
+ : isV16Plus
33
+ ? // @ts-expect-error - fetchExternalImage signature varies across Next.js versions
34
+ fetchExternalImage(href, false)
35
+ : isV15After15510
36
+ ? // @ts-expect-error - fetchExternalImage signature varies across Next.js versions
37
+ fetchExternalImage(href, maximumResponseBody)
38
+ : // @ts-expect-error - fetchExternalImage signature varies across Next.js versions
39
+ fetchExternalImage(href))
22
40
  : await (isNewArgsForInternalFetch
23
41
  ? fetchInternalImage(href,
24
42
  // @ts-expect-error - It is supposed to be an IncomingMessage object, but only the headers are used.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "access": "public"
4
4
  },
5
5
  "name": "@opennextjs/aws",
6
- "version": "4.0.1",
6
+ "version": "4.0.2",
7
7
  "bin": {
8
8
  "open-next": "./dist/index.js"
9
9
  },
@@ -60,7 +60,7 @@
60
60
  "typescript": "5.9.3"
61
61
  },
62
62
  "peerDependencies": {
63
- "next": ">=15.5.16 <16 || >=16.2.5"
63
+ "next": ">=15.5.18 <16 || >=16.2.6"
64
64
  },
65
65
  "bugs": {
66
66
  "url": "https://github.com/opennextjs/opennextjs-aws/issues"