-
Notifications
You must be signed in to change notification settings - Fork 40
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
1 parent
94b910e
commit a8f994a
Showing
16 changed files
with
433 additions
and
676 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
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
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,14 @@ | ||
import { cookies, draftMode } from "next/headers"; | ||
|
||
export function POST(req: Request) { | ||
if (req.headers.get("origin") !== new URL(req.url).origin) { | ||
return new Response("Invalid origin", { status: 400 }); | ||
} | ||
const referrer = req.headers.get("Referer"); | ||
if (!referrer) { | ||
return new Response("Missing Referer", { status: 400 }); | ||
} | ||
draftMode().disable(); | ||
cookies().delete("ks-branch"); | ||
return Response.redirect(referrer, 303); | ||
} |
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,20 @@ | ||
import { redirect } from "next/navigation"; | ||
import { draftMode, cookies } from "next/headers"; | ||
|
||
export async function GET(req: Request) { | ||
const url = new URL(req.url); | ||
const params = url.searchParams; | ||
const branch = params.get("branch"); | ||
const to = params.get("to"); | ||
console.log(to); | ||
console.log(branch); | ||
if (!branch || !to) { | ||
return new Response("Missing branch or to params", { status: 400 }); | ||
} | ||
draftMode().enable(); | ||
cookies().set("ks-branch", branch); | ||
const toUrl = new URL(to, url.origin); | ||
toUrl.protocol = url.protocol; | ||
toUrl.host = url.host; | ||
redirect(toUrl.toString()); | ||
} |
Oops, something went wrong.