Skip to content

Commit

Permalink
Fix: not using base path for urls
Browse files Browse the repository at this point in the history
  • Loading branch information
typicalninja committed Sep 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 892f934 commit f6e8ae8
Showing 5 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/components/commandList.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { base } from '$app/paths';
import { fetchAPI } from '$lib/api';
import { typeToName, type DiscordInteraction } from '$lib/constants';
import { fetchCommands } from '$lib/user';
@@ -73,7 +74,7 @@
{#if loading}
<tr>
<td colspan={headers.length} class="p-4">
<img src="/slash.png" alt="loading..." class="animate-spin w-11 h-11 mx-auto" />
<img src="{base}/slash.png" alt="loading..." class="animate-spin w-11 h-11 mx-auto" />
</td>
</tr>
{:else if error}
6 changes: 3 additions & 3 deletions src/components/header.svelte
Original file line number Diff line number Diff line change
@@ -11,10 +11,10 @@
</a>
<div class="w-full block flex-grow lg:flex lg:items-center lg:w-auto">
<div class="text-sm lg:flex-grow">
<a href="#responsive-header" class="block mt-4 lg:inline-block font-semibold lg:mt-0 text-blurple-200 hover:underline mr-4">
<!-- <a href="#responsive-header" class="block mt-4 lg:inline-block font-semibold lg:mt-0 text-blurple-200 hover:underline mr-4">
Add command
</a>
<a href="/dashboard" class="block mt-4 lg:inline-block lg:mt-0 font-semibold text-blurple-200 hover:underline mr-4">
</a> -->
<a href="{base}/dashboard" class="block mt-4 lg:inline-block lg:mt-0 font-semibold text-blurple-200 hover:underline mr-4">
Dashboard
</a>
</div>
7 changes: 5 additions & 2 deletions src/routes/dashboard/+page.svelte
Original file line number Diff line number Diff line change
@@ -5,10 +5,13 @@
import CommandList from '$components/commandList.svelte';
import { discordIdRegex } from '$lib/constants';
import { goto } from '$app/navigation';
import {browser} from "$app/environment";
import { base } from '$app/paths';
const appInfo = get(applicationInfo);
$: searchParams = browser && $page.url.searchParams
$: guildId = $page.url.searchParams.get('guildId') || '';
$: guildId = searchParams && searchParams.get('guildId') || '';
$: basePath =
guildId && discordIdRegex.test(guildId)
? `/applications/${appInfo.id}/guilds/${guildId}/commands`
@@ -40,7 +43,7 @@
You are currently viewing the list for specific guild with id "{guildId}"
Click the below button to view the global list
</p>
<a href="/dashboard" class="bg-emerald-500 hover:bg-emerald-600 p-2 rounded-lg"
<a href="{base}/dashboard" class="bg-emerald-500 hover:bg-emerald-600 p-2 rounded-lg"
>View global commands</a
>
{:else}
5 changes: 3 additions & 2 deletions src/routes/login/+page.svelte
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import { fetchUser } from '$lib/user';
import { discordIdRegex } from '$lib/constants';
import { getAccessToken } from '$lib/api';
import { base } from '$app/paths';
let auth = get(authStore);
@@ -34,7 +35,7 @@
id
});
goto('/dashboard')
goto(`${base}/dashboard`)
}
catch(err) {
console.log('Error while verifying', err)
@@ -47,7 +48,7 @@
onMount(() => {
// if token is present immediately redirect to the dashboard
if(auth.accessToken !== '') goto('/dashboard')
if(auth.accessToken !== '') goto(`${base}/dashboard`)
});
</script>
5 changes: 3 additions & 2 deletions src/routes/logout/+page.svelte
Original file line number Diff line number Diff line change
@@ -3,18 +3,19 @@
import { onMount } from 'svelte';
import { get } from 'svelte/store';
import { goto } from '$app/navigation'
import { base } from '$app/paths';
let auth = get(authStore);
function logout() {
authStore.update((p) => ({ ...p, accessToken: '' }))
applicationInfo.set({ username: '', discriminator: '', id: '' });
// redirect to login
goto('/login');
goto(`${base}/login`);
}
onMount(() => {
if(auth.accessToken === '') goto('/login')
if(auth.accessToken === '') goto(`${base}/login`)
});
</script>

0 comments on commit f6e8ae8

Please sign in to comment.