Skip to content

Commit 6f7c130

Browse files
author
Nicolas Dorseuil
committed
fix cache control for static page with base path
1 parent 3ec12c9 commit 6f7c130

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/afraid-trees-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/aws": patch
3+
---
4+
5+
fix cache control headers for fully static page with base path

packages/open-next/src/core/routing/util.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ export function fixCacheHeaderForHtmlPages(
245245
// https://opennext.js.org/aws/v2/advanced/workaround#workaround-nextserver-does-not-set-cache-headers-for-html-pages
246246
// Requests containing an `x-middleware-prefetch` header must not be cached
247247
if (
248-
HtmlPages.includes(localizedPath) &&
248+
HtmlPages.find(
249+
(path) => `${NextConfig.basePath ?? ""}${path}` === localizedPath,
250+
) &&
249251
!internalEvent.headers["x-middleware-prefetch"]
250252
) {
251253
headers[CommonHeaders.CACHE_CONTROL] =

0 commit comments

Comments
 (0)