feat: 404 for not found subdomain

This commit is contained in:
Rotimi Best
2023-12-11 03:27:13 +03:00
parent b7f9d145de
commit 820a59c80e
2 changed files with 17 additions and 15 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
// import { redirect } from '@sveltejs/kit'; import { redirect } from '@sveltejs/kit';
import { blockedSubdomain } from '$lib/utils/constants/app'; import { blockedSubdomain } from '$lib/utils/constants/app';
import { getCurrentOrg } from '$lib/utils/services/org'; import { getCurrentOrg } from '$lib/utils/services/org';
import { getSupabase, supabase } from '$lib/utils/functions/supabase'; import { getSupabase, supabase } from '$lib/utils/functions/supabase';
@@ -36,6 +36,10 @@ export const load = async ({ url, cookies }): Promise<LoadOutput> => {
response.isOrgSite = debugMode || answer; response.isOrgSite = debugMode || answer;
response.orgSiteName = debugMode ? _orgSiteName : subdomain; response.orgSiteName = debugMode ? _orgSiteName : subdomain;
response.org = (await getCurrentOrg(response.orgSiteName, true)) || null; response.org = (await getCurrentOrg(response.orgSiteName, true)) || null;
if (!response.org) {
throw redirect(302, '/404?type=org');
}
} else if (subdomain === 'play' || debugPlay === 'true') { } else if (subdomain === 'play' || debugPlay === 'true') {
response.skipAuth = true; response.skipAuth = true;
} }
+12 -14
View File
@@ -1,10 +1,13 @@
<script> <script>
import { page } from '$app/stores';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { appStore } from '$lib/utils/store/app'; import { appStore } from '$lib/utils/store/app';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte'; import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
const src = './bg-404.png'; const src = './bg-404.png';
let query = new URLSearchParams($page.url.search);
let isOrg = query.get('type') === 'org';
</script> </script>
<div <div
@@ -13,26 +16,21 @@
> >
<div class=" dark:text-white gap-3 w-4/5 lg:w-2/5"> <div class=" dark:text-white gap-3 w-4/5 lg:w-2/5">
<p class="text-3xl dark:text-white font-semibold mb-5"> <p class="text-3xl dark:text-white font-semibold mb-5">
Oops😕,where did the page go? {#if isOrg}
Oops😕, this organization doesn't exist!
{:else}
Oops😕,where did the page go?
{/if}
</p> </p>
<p class="text-base text-gray-600 dark:text-white mb-5"> <p class="text-base text-gray-600 dark:text-white mb-5">
We're sorry, but something went wrong and we can't show you the page We're sorry, but something went wrong and we can't show you the page you're looking for. In
you're looking for. In the meantime, here's a joke to make you laugh:<br the meantime, here's a joke to make you laugh:<br />
/>
What do you call a fish with no eyes? Fsh! What do you call a fish with no eyes? Fsh!
</p> </p>
<PrimaryButton <PrimaryButton label="Go to Home" className="rounded-md" onClick={() => goto('/')} />
label="Go to Home"
className="rounded-md"
onClick={() => goto('/')}
/>
</div> </div>
<img <img src="/classroom-404.png" alt="classroomio_error_image" class="errorImg" />
src="/classroom-404.png"
alt="classroomio_error_image"
class="errorImg"
/>
</div> </div>
<style> <style>