diff --git a/.changeset/afraid-trees-bathe.md b/.changeset/afraid-trees-bathe.md new file mode 100644 index 00000000..5aee5409 --- /dev/null +++ b/.changeset/afraid-trees-bathe.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/aws": patch +--- + +fix cache control headers for fully static page with base path diff --git a/packages/open-next/src/core/routing/util.ts b/packages/open-next/src/core/routing/util.ts index 70ae5302..ddc82cd1 100644 --- a/packages/open-next/src/core/routing/util.ts +++ b/packages/open-next/src/core/routing/util.ts @@ -245,7 +245,9 @@ export function fixCacheHeaderForHtmlPages( // https://opennext.js.org/aws/v2/advanced/workaround#workaround-nextserver-does-not-set-cache-headers-for-html-pages // Requests containing an `x-middleware-prefetch` header must not be cached if ( - HtmlPages.includes(localizedPath) && + HtmlPages.find( + (path) => `${NextConfig.basePath ?? ""}${path}` === localizedPath, + ) && !internalEvent.headers["x-middleware-prefetch"] ) { headers[CommonHeaders.CACHE_CONTROL] =