diff --git a/.changeset/orange-kids-sort.md b/.changeset/orange-kids-sort.md new file mode 100644 index 000000000..6a2951ff2 --- /dev/null +++ b/.changeset/orange-kids-sort.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/aws": patch +--- + +Fix incorrect status code being sent from interceptor diff --git a/packages/open-next/src/core/routing/cacheInterceptor.ts b/packages/open-next/src/core/routing/cacheInterceptor.ts index 8f34f0ae0..0a33e3824 100644 --- a/packages/open-next/src/core/routing/cacheInterceptor.ts +++ b/packages/open-next/src/core/routing/cacheInterceptor.ts @@ -119,7 +119,8 @@ async function generateResult( ); return { type: "core", - statusCode: 200, + // sometimes other status codes can be cached, like 404. For these cases, we should return the correct status code + statusCode: cachedValue.meta?.status ?? 200, body: toReadableStream(body, false), isBase64Encoded: false, headers: {