This commit is contained in:
Niki Wix Skaarup 2025-04-05 23:38:21 +02:00
parent 09557ee3ac
commit db292ea0a8
Signed by: nikiskaarup
GPG key ID: FC2F1B116F6E788C
5 changed files with 18 additions and 11 deletions

View file

@ -36,10 +36,6 @@
<svelte:window bind:scrollY={y} /> <svelte:window bind:scrollY={y} />
<svelte:head>
<link rel="preload" type="application/json" as="json" href="/api/entries" />
</svelte:head>
<div class="relative col-[content] pr-0.5"> <div class="relative col-[content] pr-0.5">
{#await entriesPromise} {#await entriesPromise}
<p class="text-center">Loading entries...</p> <p class="text-center">Loading entries...</p>

File diff suppressed because one or more lines are too long

View file

@ -1,9 +1,9 @@
<script lang="ts"> <script lang="ts">
import './index.css';
import Header from './components/header.svelte'; import Header from './components/header.svelte';
import Main from './components/main.svelte';
import Login from './components/login.svelte'; import Login from './components/login.svelte';
import Main from './components/main.svelte';
import ProgressTable from './components/progress-table.svelte'; import ProgressTable from './components/progress-table.svelte';
import './index.css';
import { userstate } from './shared.svelte'; import { userstate } from './shared.svelte';
</script> </script>
@ -13,6 +13,13 @@
> >
Skip to main content Skip to main content
</a> </a>
<svelte:head>
{#if userstate.isLoggedIn}
<link rel="preload" type="application/json" as="fetch" href="/api/entries" />
{/if}
</svelte:head>
<Header></Header> <Header></Header>
<Main> <Main>
{#if !userstate.isLoggedIn} {#if !userstate.isLoggedIn}

View file

@ -38,7 +38,11 @@ Bun.serve({
const data = await ptApi.query(); const data = await ptApi.query();
const body = JSON.stringify(data); const body = JSON.stringify(data);
return new Response(body, { headers: { 'Content-Type': 'application/json' } }); return new Response(body, {
headers: {
'Content-Type': 'application/json'
}
});
}, },
}, },
'/auth/logout': { '/auth/logout': {
@ -48,7 +52,8 @@ Bun.serve({
}, },
'/auth/login': { '/auth/login': {
async POST(req) { async POST(req) {
const data = await req.json(); const json = await req.json();
const data = json as Record<string, any>;
const email = data.email; const email = data.email;
const password = data.password; const password = data.password;

View file

@ -13,8 +13,7 @@ export async function fetchEntries(): Promise<SelectBookmark[]> {
try { try {
const response = await fetch('/api/entries', { const response = await fetch('/api/entries', {
method: 'GET', method: 'GET',
credentials: 'include', mode: 'no-cors'
mode: 'same-origin',
}); });
if (!response.ok) { if (!response.ok) {