@netlify/plugin-nextjs 4.24.1 → 4.24.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.
- package/lib/templates/ipx.js +1 -0
- package/package.json +2 -2
- package/src/templates/edge/ipx.ts +24 -3
package/lib/templates/ipx.js
CHANGED
|
@@ -9,5 +9,6 @@ exports.handler = (0, ipx_1.createIPXHandler)({
|
|
|
9
9
|
domains: imageconfig_json_1.domains,
|
|
10
10
|
remotePatterns: imageconfig_json_1.remotePatterns,
|
|
11
11
|
responseHeaders: imageconfig_json_1.responseHeaders,
|
|
12
|
+
localPrefix: '/_next/static/media/',
|
|
12
13
|
});
|
|
13
14
|
/* eslint-enable n/no-missing-import, import/no-unresolved, @typescript-eslint/ban-ts-comment */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.24.
|
|
3
|
+
"version": "4.24.2",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@netlify/esbuild": "0.14.39",
|
|
14
14
|
"@netlify/functions": "^1.3.0",
|
|
15
|
-
"@netlify/ipx": "^1.
|
|
15
|
+
"@netlify/ipx": "^1.3.0",
|
|
16
16
|
"@vercel/node-bridge": "^2.1.0",
|
|
17
17
|
"chalk": "^4.1.2",
|
|
18
18
|
"destr": "^1.1.1",
|
|
@@ -9,6 +9,9 @@ interface ImageConfig extends Record<string, unknown> {
|
|
|
9
9
|
formats?: string[]
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// Checks if a URL param is numeric
|
|
13
|
+
const isNumeric = (value: string | null) => Number(value).toString() === value
|
|
14
|
+
|
|
12
15
|
/**
|
|
13
16
|
* Implement content negotiation for images
|
|
14
17
|
*/
|
|
@@ -28,10 +31,28 @@ const handler = async (req: Request, context: Context) => {
|
|
|
28
31
|
|
|
29
32
|
const source = searchParams.get('url')
|
|
30
33
|
const width = searchParams.get('w')
|
|
31
|
-
const quality = searchParams.get('q') ?? 75
|
|
34
|
+
const quality = searchParams.get('q') ?? '75'
|
|
35
|
+
|
|
36
|
+
const errors: Array<string> = []
|
|
37
|
+
|
|
38
|
+
if (!source) {
|
|
39
|
+
errors.push('Missing "url" parameter')
|
|
40
|
+
} else if (!source.startsWith('http') && !source.startsWith('/')) {
|
|
41
|
+
errors.push('The "url" parameter must be a valid URL or path')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!width) {
|
|
45
|
+
errors.push('Missing "w" parameter')
|
|
46
|
+
} else if (!isNumeric(width)) {
|
|
47
|
+
errors.push('Invalid "w" parameter')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!isNumeric(quality)) {
|
|
51
|
+
errors.push('Invalid "q" parameter')
|
|
52
|
+
}
|
|
32
53
|
|
|
33
|
-
if (!source ||
|
|
34
|
-
return new Response(
|
|
54
|
+
if (!source || errors.length > 0) {
|
|
55
|
+
return new Response(`Invalid request: \n${errors.join('\n')}`, {
|
|
35
56
|
status: 400,
|
|
36
57
|
})
|
|
37
58
|
}
|