@netlify/plugin-nextjs 4.24.0 → 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.
|
@@ -102,8 +102,15 @@ const makeHandler = (conf, app, pageRoot, staticManifest = [], mode = 'ssr') =>
|
|
|
102
102
|
const ttl = getMaxAge(cacheHeader);
|
|
103
103
|
// Long-expiry TTL is basically no TTL, so we'll skip it
|
|
104
104
|
if (ttl > 0 && ttl < ONE_YEAR_IN_SECONDS) {
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
// ODBs currently have a minimum TTL of 60 seconds
|
|
106
|
+
result.ttl = Math.max(ttl, 60);
|
|
107
|
+
}
|
|
108
|
+
// Only cache 404s ephemerally
|
|
109
|
+
if (ttl === ONE_YEAR_IN_SECONDS && result.statusCode === 404) {
|
|
110
|
+
result.ttl = 60;
|
|
111
|
+
}
|
|
112
|
+
if (result.ttl > 0) {
|
|
113
|
+
requestMode = `odb ttl=${result.ttl}`;
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
multiValueHeaders['cache-control'] = ['public, max-age=0, must-revalidate'];
|
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": [
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@netlify/esbuild": "0.14.39",
|
|
14
|
-
"@netlify/functions": "^1.
|
|
15
|
-
"@netlify/ipx": "^1.
|
|
14
|
+
"@netlify/functions": "^1.3.0",
|
|
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
|
}
|