fix: set cookie in header on rewrite

This commit is contained in:
Christel Westerberg
2024-05-07 12:10:25 +02:00
parent b58b5f368d
commit 777fd1e5b6
4 changed files with 38 additions and 12 deletions

View File

@@ -10,8 +10,6 @@ import { serverClient } from "@/lib/trpc/server"
import MaxWidth from "@/components/MaxWidth"
import Content from "@/components/MyPages/AccountPage/Webview/Content"
import Link from "@/components/TempDesignSystem/Link"
import Title from "@/components/Title"
import styles from "./page.module.css"
@@ -39,6 +37,18 @@ export default async function MyPages({
return notFound()
}
// Check if the access token is valid. If not, redirect to the refresh page.
await serverClient({
onError(opts) {
const returnUrl = new URLSearchParams({
returnurl: `${params.lang}/webview/${searchParams.uri}`,
})
const refreshUrl = `/${params.lang}/webview/refresh?${returnUrl.toString()}`
redirect(refreshUrl)
},
}).user.get()
const accountPage = await serverClient({
onError() {
const returnUrl = new URLSearchParams({
@@ -57,10 +67,6 @@ export default async function MyPages({
return (
<MaxWidth className={styles.blocks} tag="main">
<header>
<Title as="h2">{_("Welcome")}</Title>
<Link href={link.href}>{link.title}</Link>
</header>
<Content lang={params.lang} content={accountPage.content} />
</MaxWidth>
)