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) => {
|
export default async (request: Request) => {
|
||||||
// Proxy the request to the `req.url` value and return it as a JSON string.
|
// Proxy the request to the `req.url` value and return it as a JSON string.
|
||||||
const params = new URL(request.url).searchParams;
|
const params = new URL(request.url).searchParams;
|
||||||
|
@ -28,7 +29,7 @@ export default async (request: Request) => {
|
||||||
}
|
}
|
||||||
return new Response(JSON.stringify(data), {
|
return new Response(JSON.stringify(data), {
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json'
|
'content-type': 'application/json',
|
||||||
'cache-control': 'public, max-age=300, must-revalidate',
|
'cache-control': 'public, max-age=300, must-revalidate',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,13 @@
|
||||||
// Request well-known/fursona file
|
// Request well-known/fursona file
|
||||||
function requestFursona() {
|
function requestFursona() {
|
||||||
fetch(`/api/${$page.params.domain}/fursona`)
|
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) => {
|
.then((data) => {
|
||||||
// Cast data to FursonaSchema
|
// Cast data to FursonaSchema
|
||||||
const sonas_data = data as FursonaSchema;
|
const sonas_data = data as FursonaSchema;
|
||||||
|
@ -42,7 +48,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<div class="m-4 max-w-md flex flex-col items-center justify-center">
|
<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">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue