@netlify/plugin-nextjs 4.31.0 → 4.32.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.32.1",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@delucis/if-env": "^1.1.2",
|
|
39
|
-
"@netlify/build": "^29.6.
|
|
39
|
+
"@netlify/build": "^29.6.8",
|
|
40
40
|
"@types/fs-extra": "^9.0.13",
|
|
41
41
|
"@types/jest": "^27.4.1",
|
|
42
42
|
"@types/merge-stream": "^1.1.2",
|
|
@@ -18,19 +18,6 @@ if (!('getAll' in Headers.prototype)) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// Check if a file exists, given a relative path
|
|
22
|
-
const exists = async (relativePath) => {
|
|
23
|
-
const path = fromFileUrl(new URL(relativePath, import.meta.url))
|
|
24
|
-
try {
|
|
25
|
-
await Deno.stat(path)
|
|
26
|
-
return true
|
|
27
|
-
} catch (error) {
|
|
28
|
-
if (error instanceof Deno.errors.NotFound) {
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
31
|
-
throw error
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
21
|
let idx = 0
|
|
35
22
|
|
|
36
23
|
const handler = async (req, context) => {
|
|
@@ -45,14 +32,19 @@ const handler = async (req, context) => {
|
|
|
45
32
|
// We don't want to just try importing and use that to test,
|
|
46
33
|
// because that would also throw if there's an error in the middleware,
|
|
47
34
|
// which we would want to surface not ignore.
|
|
48
|
-
|
|
35
|
+
try {
|
|
49
36
|
// We need to cache-bust the import because otherwise it will claim it
|
|
50
37
|
// doesn't exist if the user creates it after the server starts
|
|
51
|
-
const nextMiddleware = await import(`../../middleware.js#${idx
|
|
38
|
+
const nextMiddleware = await import(`../../middleware.js#${++idx}`)
|
|
52
39
|
middleware = nextMiddleware.middleware
|
|
53
|
-
}
|
|
54
|
-
//
|
|
55
|
-
|
|
40
|
+
} catch (importError) {
|
|
41
|
+
// Error message is `Module not found "file://<path>/middleware.js#123456".` in Deno
|
|
42
|
+
if (importError.code === 'ERR_MODULE_NOT_FOUND' && importError.message.includes(`middleware.js#${idx}`)) {
|
|
43
|
+
// No middleware, so we silently return
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
throw importError
|
|
56
48
|
}
|
|
57
49
|
|
|
58
50
|
// This is the format expected by Next.js along with the timezone which we support.
|
|
@@ -31,12 +31,11 @@ export const addMiddlewareHeaders = async (
|
|
|
31
31
|
// We need to await the response to get the origin headers, then we can add the ones from middleware.
|
|
32
32
|
const res = await originResponse
|
|
33
33
|
const response = new Response(res.body, res)
|
|
34
|
-
const originCookies = response.headers.get('set-cookie')
|
|
35
34
|
middlewareResponse.headers.forEach((value, key) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
response.headers.
|
|
35
|
+
if (key === 'set-cookie') {
|
|
36
|
+
response.headers.append(key, value)
|
|
37
|
+
} else {
|
|
38
|
+
response.headers.set(key, value)
|
|
40
39
|
}
|
|
41
40
|
})
|
|
42
41
|
return response
|