-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
97 changed files
with
1,170 additions
and
1,092 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {NextResponse} from "next/server"; | ||
import {cookies} from "next/headers"; | ||
|
||
export const revalidate = 0; | ||
|
||
export async function GET() { | ||
cookies().delete("preview"); | ||
return NextResponse.json({disabled: true}, {status: 200}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import {NextRequest, NextResponse} from "next/server"; | ||
import {redirect} from 'next/navigation' | ||
import {redirect} from "next/navigation" | ||
import {cookies} from "next/headers"; | ||
|
||
export const revalidate = 0; | ||
|
||
export async function GET(request: NextRequest) { | ||
|
||
const secret = request.nextUrl.searchParams.get('secret') | ||
const slug = request.nextUrl.searchParams.get('slug') | ||
const secret = request.nextUrl.searchParams.get("secret") | ||
const slug = request.nextUrl.searchParams.get("slug") | ||
|
||
// Check the secret and next parameters | ||
// This secret should only be known to this route handler and the CMS | ||
if (secret !== process.env.DRUPAL_PREVIEW_SECRET) { | ||
return NextResponse.json({message: 'Invalid token'}, {status: 401}) | ||
return NextResponse.json({message: "Invalid token"}, {status: 401}) | ||
} | ||
|
||
if (!slug) { | ||
return NextResponse.json({message: 'Invalid slug path'}, {status: 401}) | ||
return NextResponse.json({message: "Invalid slug path"}, {status: 401}) | ||
} | ||
cookies().set('preview', secret, { | ||
cookies().set("preview", secret, { | ||
maxAge: 60 * 60, | ||
httpOnly: true, | ||
sameSite: 'none', | ||
sameSite: "none", | ||
secure: true, | ||
partitioned: true, | ||
}); | ||
|
||
// Redirect to the path from the fetched post | ||
// We don't redirect to searchParams.slug as that might lead to open redirect vulnerabilities | ||
redirect(`/preview/${slug}`) | ||
// We don"t redirect to searchParams.slug as that might lead to open redirect vulnerabilities | ||
redirect(`/preview${slug === "/home" ? "" : slug}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.