@akinon/next 1.47.0-rc.4 → 1.47.0-rc.6
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/CHANGELOG.md +12 -0
- package/api/client.ts +11 -8
- package/middlewares/default.ts +19 -1
- package/package.json +2 -2
- package/types/index.ts +1 -0
- package/utils/app-fetch.ts +1 -0
- package/utils/server-variables.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.47.0-rc.6
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c670bd4: ZERO-2900: Add middleware rewrite functionality
|
|
8
|
+
|
|
9
|
+
## 1.47.0-rc.5
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- b9273fd: ZERO-2889: add host headers to requests
|
|
14
|
+
|
|
3
15
|
## 1.47.0-rc.4
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/api/client.ts
CHANGED
|
@@ -52,18 +52,24 @@ async function proxyRequest(...args) {
|
|
|
52
52
|
extraHeaders[key.toLowerCase()] = value;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
[
|
|
55
|
+
const excludedHeaders = [
|
|
56
56
|
'x-forwarded-host',
|
|
57
57
|
'x-forwarded-proto',
|
|
58
58
|
'x-forwarded-port',
|
|
59
59
|
'x-requested-with',
|
|
60
60
|
'origin',
|
|
61
|
-
'host',
|
|
62
61
|
'referer',
|
|
63
62
|
'accept',
|
|
64
63
|
'content-length',
|
|
65
|
-
'content-type'
|
|
66
|
-
|
|
64
|
+
'content-type',
|
|
65
|
+
'host'
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
excludedHeaders.forEach((header) => {
|
|
69
|
+
if (!settings.includedProxyHeaders?.includes(header)) {
|
|
70
|
+
delete extraHeaders[header];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
67
73
|
|
|
68
74
|
const fetchOptions = {
|
|
69
75
|
method: req.method,
|
|
@@ -146,11 +152,8 @@ async function proxyRequest(...args) {
|
|
|
146
152
|
try {
|
|
147
153
|
const request = await fetch(url, fetchOptions);
|
|
148
154
|
|
|
149
|
-
// Using NextResponse.json with status 204 will cause an error
|
|
150
155
|
if (request.status === 204) {
|
|
151
|
-
return new Response(null, {
|
|
152
|
-
status: 204
|
|
153
|
-
});
|
|
156
|
+
return new Response(null, { status: 204 });
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
let response = {} as any;
|
package/middlewares/default.ts
CHANGED
|
@@ -269,8 +269,26 @@ const withPzDefault =
|
|
|
269
269
|
if (
|
|
270
270
|
middlewareResult.headers.get(
|
|
271
271
|
'pz-override-response'
|
|
272
|
-
)
|
|
272
|
+
) === 'true'
|
|
273
273
|
) {
|
|
274
|
+
if (
|
|
275
|
+
middlewareResult.headers.get(
|
|
276
|
+
'x-middleware-rewrite'
|
|
277
|
+
)
|
|
278
|
+
) {
|
|
279
|
+
const rewriteUrl = new URL(
|
|
280
|
+
middlewareResult.headers.get(
|
|
281
|
+
'x-middleware-rewrite'
|
|
282
|
+
)
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
url.pathname = (
|
|
286
|
+
url.pathname + rewriteUrl.pathname
|
|
287
|
+
).replace(/\/\//g, '/');
|
|
288
|
+
|
|
289
|
+
return NextResponse.rewrite(url);
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
274
292
|
middlewareResult.headers.set(
|
|
275
293
|
'x-middleware-rewrite',
|
|
276
294
|
url.href
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.47.0-rc.
|
|
4
|
+
"version": "1.47.0-rc.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"set-cookie-parser": "2.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "1.47.0-rc.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "1.47.0-rc.6",
|
|
34
34
|
"@types/react-redux": "7.1.30",
|
|
35
35
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
package/types/index.ts
CHANGED
package/utils/app-fetch.ts
CHANGED