misc: switch to csr

This commit is contained in:
Xyphyn committed 2023-07-30 11:55:04 -07:00
1 parent 8721e61554
commit eb1d90478e
6 files changed
+20 -25

No files matched your search

+7
View File
@@ -14,4 +14,11 @@
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
<style>
@media (prefers-color-scheme: dark) {
:root {
background-color: black;
}
}
</style>
</html>
+9
View File
@@ -35,6 +35,15 @@ export async function handle({ event, resolve }) {
url.searchParams.get('auth')
) {
headers.set('cookie', `jwt=${url.searchParams.get('auth')}`)
} else {
return new Response(
JSON.stringify({
message: 'Only CORS allowed is through /pictrs/image',
}),
{
status: 500,
}
)
}
const data = await fetch(url, {
+1 -14
View File
@@ -8,26 +8,13 @@ import { amModOfAny } from '$lib/components/lemmy/moderation/moderation.js'
export const LINKED_INSTANCE_URL = env.PUBLIC_INSTANCE_URL
export const DEFAULT_INSTANCE_URL = env.PUBLIC_INSTANCE_URL || 'lemmy.ml'
export let instance = writable(DEFAULT_INSTANCE_URL)
export let corsSupported = writable(true)
export function buildBaseUrl(instanceURL?: string) {
if (!instanceURL) {
instanceURL = get(instance)!
}
return `${env.PUBLIC_PROXY_URL!}/cors/${instanceURL}`
}
export function getClient(instanceURL?: string): LemmyHttp {
if (!instanceURL) {
instanceURL = get(instance)
}
return new LemmyHttp(
get(corsSupported)
? `https://${instanceURL}`
: `${env.PUBLIC_PROXY_URL}/cors/${instanceURL}`
)
return new LemmyHttp(`https://${instanceURL}`)
}
export const getInstance = () => get(instance)
+1 -10
View File
@@ -3,22 +3,13 @@
import { page } from '$app/stores'
import Button from '$lib/components/input/Button.svelte'
import Link from '$lib/components/input/Link.svelte'
import { corsSupported } from '$lib/lemmy.js'
</script>
<div class="flex flex-col mx-auto gap-4 justify-center items-center">
<h1 class="font-black text-5xl">{$page.status}</h1>
<p>
The <strong>server</strong>
failed to fetch the data. Click "retry" to have the client load it.
failed to fetch the data. Click "retry" to have the client load it.
</p>
<Button href={$page.url.toString()}>Retry</Button>
<Button
on:click={() => {
corsSupported.set(false)
goto($page.url.toString())
}}
>
Retry through proxy
</Button>
</div>
+1
View File
@@ -0,0 +1 @@
export let ssr = false
+1 -1
View File
@@ -4,7 +4,7 @@
:root {
@apply bg-slate-50 dark:bg-zinc-950 text-slate-900
dark:text-zinc-100;
dark:text-zinc-100 !important;
}
@media (prefers-color-scheme: dark) {