@opennextjs/aws 4.0.0 → 4.0.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.
|
@@ -119,7 +119,7 @@ async function generateResult(event, localizedPath, cachedValue, lastModified, i
|
|
|
119
119
|
let isDataRequest = false;
|
|
120
120
|
let additionalHeaders = {};
|
|
121
121
|
if (cachedValue.type === "app") {
|
|
122
|
-
isDataRequest =
|
|
122
|
+
isDataRequest = event.headers.rsc === "1";
|
|
123
123
|
if (isDataRequest) {
|
|
124
124
|
const { body: appRouterBody, additionalHeaders: appHeaders } = getBodyForAppRouter(event, cachedValue);
|
|
125
125
|
body = appRouterBody;
|
|
@@ -208,7 +208,7 @@ function handleTrailingSlashRedirect(event) {
|
|
|
208
208
|
}
|
|
209
209
|
const emptyBody = emptyReadableStream();
|
|
210
210
|
if (NextConfig.trailingSlash &&
|
|
211
|
-
!event.
|
|
211
|
+
!(event.query.__nextDataReq === "1") &&
|
|
212
212
|
!event.rawPath.endsWith("/") &&
|
|
213
213
|
!event.rawPath.match(/[\w-]+\.[\w]+$/g)) {
|
|
214
214
|
const headersLocation = event.url.split("?");
|
|
@@ -23,6 +23,22 @@ const geoHeaderToNextHeader = {
|
|
|
23
23
|
"x-open-next-latitude": "x-vercel-ip-latitude",
|
|
24
24
|
"x-open-next-longitude": "x-vercel-ip-longitude",
|
|
25
25
|
};
|
|
26
|
+
// Those are internal headers from Next.js that should not be set by users
|
|
27
|
+
// We strip them for the incoming request - To be updated when Next.js adds new internal headers
|
|
28
|
+
// https://github.com/vercel/next.js/blob/ed1c6cc/packages/next/src/server/lib/server-ipc/utils.ts#L42-L53
|
|
29
|
+
// NOTE: Use lowercase format.
|
|
30
|
+
const NEXT_INTERNAL_HEADERS = [
|
|
31
|
+
"x-middleware-rewrite",
|
|
32
|
+
"x-middleware-redirect",
|
|
33
|
+
"x-middleware-set-cookie",
|
|
34
|
+
"x-middleware-skip",
|
|
35
|
+
"x-middleware-override-headers",
|
|
36
|
+
"x-middleware-next",
|
|
37
|
+
"x-now-route-matches",
|
|
38
|
+
"x-matched-path",
|
|
39
|
+
"x-nextjs-data",
|
|
40
|
+
"x-next-resume-state-length",
|
|
41
|
+
];
|
|
26
42
|
/**
|
|
27
43
|
* Adds the middleware headers to an event or result.
|
|
28
44
|
*
|
|
@@ -53,8 +69,10 @@ export default async function routingHandler(event, { assetResolver }) {
|
|
|
53
69
|
// First we remove internal headers
|
|
54
70
|
// We don't want to allow users to set these headers
|
|
55
71
|
for (const key of Object.keys(event.headers)) {
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
const lowerCaseKey = key.toLowerCase();
|
|
73
|
+
if (lowerCaseKey.startsWith(INTERNAL_HEADER_PREFIX) ||
|
|
74
|
+
lowerCaseKey.startsWith(MIDDLEWARE_HEADER_PREFIX) ||
|
|
75
|
+
NEXT_INTERNAL_HEADERS.includes(lowerCaseKey)) {
|
|
58
76
|
delete event.headers[key];
|
|
59
77
|
}
|
|
60
78
|
}
|