Slightly better handling of 404s etc
This commit is contained in:
parent
c20ca36a41
commit
b4c4cc2148
|
@ -18,6 +18,7 @@ async function fetcher(url: string) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
export default async (request: Request) => {
|
||||
// Proxy the request to the `req.url` value and return it as a JSON string.
|
||||
const params = new URL(request.url).searchParams;
|
||||
|
@ -28,7 +29,7 @@ export default async (request: Request) => {
|
|||
}
|
||||
return new Response(JSON.stringify(data), {
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
'content-type': 'application/json',
|
||||
'cache-control': 'public, max-age=300, must-revalidate',
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,7 +16,13 @@
|
|||
// Request well-known/fursona file
|
||||
function requestFursona() {
|
||||
fetch(`/api/${$page.params.domain}/fursona`)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
} else {
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
// Cast data to FursonaSchema
|
||||
const sonas_data = data as FursonaSchema;
|
||||
|
@ -42,7 +48,7 @@
|
|||
{:else}
|
||||
<div class="m-4 max-w-md flex flex-col items-center justify-center">
|
||||
<div class="w-full max-w-sm p-4 dark:bg-slate-500 bg-white rounded-md shadow-md">
|
||||
<p class="mb-3 text-center">Loading...</p>
|
||||
<p class="mb-3 text-center text-slate-900 dark:text-white">Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
Loading…
Reference in a new issue