Skip to content

Commit ba6fe5e

Browse files
committed
Update root.astro
1 parent 97521b3 commit ba6fe5e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

apps/marketing-astro/src/layouts/root.astro

+8-2
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,21 @@ const { title, description, viewTransitions } = Astro.props;
198198
}
199199
</style>
200200

201-
<script data-astro-rerun>
202-
fetch("https://auth.pixeleye.io/sessions/whoami", {
201+
<script>
202+
const loggedIn = await fetch("https://auth.pixeleye.io/sessions/whoami", {
203203
credentials: "include",
204204
})
205205
.then((res) => !res.ok && Promise.reject(res))
206206
.then(() => {
207207
document.documentElement.setAttribute("data-logged-in", "true");
208+
return "true";
208209
})
209210
.catch(() => {
210211
document.documentElement.setAttribute("data-logged-in", "false");
212+
return "false";
211213
});
214+
215+
document.addEventListener("astro:after-swap", () => {
216+
document.documentElement.setAttribute("data-logged-in", loggedIn);
217+
});
212218
</script>

0 commit comments

Comments
 (0)