Skip to content

Commit eba5d09

Browse files
committed
hotfix: cachedFetcher's domain mappings have to be called before accessing them
1 parent 4595b60 commit eba5d09

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

middleware.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,12 @@ export async function middleware (request) {
234234
const mainDomain = new URL(process.env.NEXT_PUBLIC_URL).host
235235
if (domain !== mainDomain) {
236236
// get the subName from the domain mappings cache
237-
const { subName } = await getDomainMappingsCache()?.[domain?.toLowerCase()]
238-
if (subName) {
239-
domainLogger().log('detected allowed custom domain for: ', subName)
237+
const cachedDomainMappings = await getDomainMappingsCache()
238+
const domainMapping = cachedDomainMappings?.[domain?.toLowerCase()]
239+
if (domainMapping) {
240+
domainLogger().log('detected allowed custom domain for: ', domainMapping.subName)
240241
// handle the custom domain
241-
const customDomainResp = await customDomainMiddleware(request, referrerResp, mainDomain, domain, subName)
242+
const customDomainResp = await customDomainMiddleware(request, referrerResp, mainDomain, domain, domainMapping.subName)
242243
return applySecurityHeaders(customDomainResp)
243244
}
244245
}

0 commit comments

Comments
 (0)