misc: Tweak CORS
This commit is contained in:
1 parent
740664d918
commit
981d1581a4
8 files changed
+39
-29
No files matched your search
@@ -74,14 +74,14 @@
|
|||||||
<div class="max-w-full break-words text-sm leading-6">
|
<div class="max-w-full break-words text-sm leading-6">
|
||||||
<Markdown source={node.comment_view.comment.content} />
|
<Markdown source={node.comment_view.comment.content} />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-2 items-center mt-1">
|
<div class="flex flex-row gap-2 items-center mt-1 h-[26px]">
|
||||||
<CommentVote
|
<CommentVote
|
||||||
bind:score={node.comment_view.counts.score}
|
bind:score={node.comment_view.counts.score}
|
||||||
bind:vote={node.comment_view.my_vote}
|
bind:vote={node.comment_view.my_vote}
|
||||||
commentId={node.comment_view.comment.id}
|
commentId={node.comment_view.comment.id}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
class="{Color.borderDark} px-2 py-1 flex flex-row items-center gap-1
|
class="{Color.borderDark} h-full px-2 flex flex-row items-center gap-1
|
||||||
rounded-md transition-colors"
|
rounded-md transition-colors"
|
||||||
on:click={() => (replying = !replying)}
|
on:click={() => (replying = !replying)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -57,12 +57,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="flex flex-row items-center rounded-md px-2 py-0.5 transition-colors
|
class="flex flex-row items-center rounded-md transition-colors
|
||||||
cursor-pointer {Color.borderDark}"
|
cursor-pointer h-full {Color.borderDark}"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
on:click={upvote}
|
on:click={upvote}
|
||||||
class="pr-1.5 {vote == 1 ? 'text-orange-500' : ''}"
|
class="px-1.5 {vote == 1 ? 'text-orange-500' : ''}"
|
||||||
aria-label="Upvote"
|
aria-label="Upvote"
|
||||||
>
|
>
|
||||||
<Icon src={ChevronUp} width={19} mini />
|
<Icon src={ChevronUp} width={19} mini />
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
on:click={downvote}
|
on:click={downvote}
|
||||||
class="pl-1.5 {vote == -1 ? 'text-blue-500' : ''}"
|
class="px-1.5 {vote == -1 ? 'text-blue-500' : ''}"
|
||||||
aria-label="Downvote"
|
aria-label="Downvote"
|
||||||
>
|
>
|
||||||
<Icon src={ChevronDown} width={19} mini />
|
<Icon src={ChevronDown} width={19} mini />
|
||||||
|
|||||||
@@ -67,17 +67,14 @@
|
|||||||
<svelte:self {post} nodes={node.children} isParent={false} />
|
<svelte:self {post} nodes={node.children} isParent={false} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
|
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
|
||||||
<div class="m-1 w-full max-w-[9rem]">
|
<Button
|
||||||
<Button
|
loading={loadingChildren}
|
||||||
loading={loadingChildren}
|
disabled={loadingChildren}
|
||||||
disabled={loadingChildren}
|
on:click={() => fetchChildren(node)}
|
||||||
on:click={() => fetchChildren(node)}
|
>
|
||||||
large
|
<Icon src={ChevronDown} width={16} mini />
|
||||||
>
|
Load {node.comment_view.counts.child_count} more
|
||||||
<Icon src={ChevronDown} width={16} mini />
|
</Button>
|
||||||
Load {node.comment_view.counts.child_count} more
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
</Comment>
|
</Comment>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
src="{url ??
|
src="{url ?? `/img/logo-background.svg`}?format=webp&thumbnail={width * 2}"
|
||||||
`https://api.dicebear.com/6.x/initials/svg?seed=${alt}`}?format=webp&thumbnail={width *
|
|
||||||
2}"
|
|
||||||
{alt}
|
{alt}
|
||||||
{width}
|
{width}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
|||||||
@@ -17,12 +17,7 @@
|
|||||||
href={linkFromCommunity(user)}
|
href={linkFromCommunity(user)}
|
||||||
>
|
>
|
||||||
{#if avatar}
|
{#if avatar}
|
||||||
<Avatar
|
<Avatar url={user.avatar} alt={user.name} width={avatarSize} />
|
||||||
url={user.avatar ??
|
|
||||||
`https://api.dicebear.com/6.x/initials/svg?seed=${user.name}`}
|
|
||||||
alt={user.name}
|
|
||||||
width={avatarSize}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
{user.name}
|
{user.name}
|
||||||
</a>
|
</a>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let date: Date
|
export let date: Date
|
||||||
export let relativeTo: Date | undefined
|
export let relativeTo: Date | undefined = undefined
|
||||||
|
|
||||||
function formatRelativeDate(date: Date) {
|
function formatRelativeDate(date: Date) {
|
||||||
const now = relativeTo?.getTime() ?? Date.now()
|
const now = relativeTo?.getTime() ?? Date.now()
|
||||||
|
|||||||
+7
-2
@@ -6,8 +6,9 @@ import {
|
|||||||
import { get, writable } from 'svelte/store'
|
import { get, writable } from 'svelte/store'
|
||||||
import { PUBLIC_PROXY_URL } from '$env/static/public'
|
import { PUBLIC_PROXY_URL } from '$env/static/public'
|
||||||
|
|
||||||
export const DEFAULT_INSTANCE_URL = 'lemmy.world'
|
export const DEFAULT_INSTANCE_URL = 'lemmy.ml'
|
||||||
export let instance_url = writable(DEFAULT_INSTANCE_URL)
|
export let instance_url = writable(DEFAULT_INSTANCE_URL)
|
||||||
|
export let corsSupported = writable(true)
|
||||||
|
|
||||||
export function buildBaseUrl(instance?: string) {
|
export function buildBaseUrl(instance?: string) {
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
@@ -22,7 +23,11 @@ export function getClient(instance?: string): LemmyHttp {
|
|||||||
instance = get(authData)?.instance ?? DEFAULT_INSTANCE_URL
|
instance = get(authData)?.instance ?? DEFAULT_INSTANCE_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LemmyHttp(`${PUBLIC_PROXY_URL}/cors/${instance}`)
|
return new LemmyHttp(
|
||||||
|
get(corsSupported)
|
||||||
|
? `https://${instance}`
|
||||||
|
: `${PUBLIC_PROXY_URL}/cors/${instance}`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getInstance = () => get(authData)?.instance ?? DEFAULT_INSTANCE_URL
|
export const getInstance = () => get(authData)?.instance ?? DEFAULT_INSTANCE_URL
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
import Link from '$lib/components/input/Link.svelte'
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
|
import { corsSupported } from '$lib/lemmy.js'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col mx-auto gap-4 justify-center items-center">
|
<div class="flex flex-col mx-auto gap-4 justify-center items-center">
|
||||||
@@ -9,8 +12,20 @@
|
|||||||
Failed to fetch page. Most major lemmy instances are having quite a lot of
|
Failed to fetch page. Most major lemmy instances are having quite a lot of
|
||||||
issues right now, this might be on their end.
|
issues right now, this might be on their end.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
This could be a CORS issue. The instance you're using must update to Lemmy
|
||||||
|
1.18.1 to fix CORS.
|
||||||
|
</p>
|
||||||
<code class="bg-slate-100 dark:bg-zinc-800 px-2 py-1 rounded-md">
|
<code class="bg-slate-100 dark:bg-zinc-800 px-2 py-1 rounded-md">
|
||||||
{JSON.stringify($page.error)}
|
{JSON.stringify($page.error)}
|
||||||
</code>
|
</code>
|
||||||
<Link href={$page.url.toString()}>Retry</Link>
|
<Link href={$page.url.toString()}>Retry</Link>
|
||||||
|
<Button
|
||||||
|
on:click={() => {
|
||||||
|
corsSupported.set(false)
|
||||||
|
goto($page.url.toString())
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Retry through proxy
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user