Merge branch 'main' of github.com:stackframe-projects/stack

This commit is contained in:
Zai Shi 2024-04-14 10:28:29 +02:00
commit 5dcc831f96
2 changed files with 15 additions and 3 deletions

View File

@ -342,7 +342,12 @@ export function redirectHandler(redirectPath: string, statusCode: 301 | 302 | 30
body: yup.string().required(),
}),
async handler(req) {
const newUrl = new URL(redirectPath, req.url + "/");
const urlWithTrailingSlash = new URL(req.url);
if (!urlWithTrailingSlash.pathname.endsWith("/")) {
urlWithTrailingSlash.pathname += "/";
}
const newUrl = new URL(redirectPath, urlWithTrailingSlash);
console.log({ req, newUrl });
return {
statusCode,
headers: {

View File

@ -4,6 +4,7 @@ import { useRouter } from "next/navigation";
import { useStackApp } from "..";
import MessageCard from "./message-card";
import { Text, Button } from "../components-core";
import { neverResolve } from "@stackframe/stack-shared/dist/utils/promises";
export default function RedirectMessageCard({
type,
@ -67,13 +68,19 @@ export default function RedirectMessageCard({
{secondaryButton && (
<Button
variant="secondary"
onClick={() => router.push(stackApp.urls.signOut.toString())}
onClick={async () => {
router.push(stackApp.urls.signOut.toString());
await neverResolve();
}}
>
{secondaryButton}
</Button>
)}
<Button onClick={() => router.push(primaryUrl.toString())}>
<Button onClick={async () => {
router.push(primaryUrl.toString());
await neverResolve();
}}>
{primaryButton}
</Button>
</div>