fix(SW-663): Fixed leaking of live preview hash and removing preview pages
This commit is contained in:
@@ -19,7 +19,6 @@ export const middleware: NextMiddleware = async (request) => {
|
||||
|
||||
const contentTypePathName = pathWithoutTrailingSlash.replace(`/${lang}`, "")
|
||||
const isPreview = request.nextUrl.pathname.includes("/preview")
|
||||
|
||||
const searchParams = new URLSearchParams(request.nextUrl.searchParams)
|
||||
|
||||
const { contentType, uid } = await fetchAndCacheEntry(
|
||||
@@ -41,21 +40,10 @@ export const middleware: NextMiddleware = async (request) => {
|
||||
const isCurrent = contentType ? contentType.indexOf("current") >= 0 : false
|
||||
|
||||
if (isPreview) {
|
||||
if (isCurrent) {
|
||||
searchParams.set("uri", contentTypePathName.replace("/preview", ""))
|
||||
return NextResponse.rewrite(
|
||||
new URL(`/${lang}/preview-current?${searchParams.toString()}`, nextUrl),
|
||||
{
|
||||
request: {
|
||||
headers,
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
searchParams.set("isPreview", "true")
|
||||
return NextResponse.rewrite(
|
||||
new URL(
|
||||
`/${lang}/preview/${contentType}/${uid}?${searchParams.toString()}`,
|
||||
`/${lang}/${contentType}/${uid}?${searchParams.toString()}`,
|
||||
nextUrl
|
||||
),
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user