Skip to content

Commit

Permalink
removed URL loading page
Browse files Browse the repository at this point in the history
- URL's now go directly to the destination
  • Loading branch information
drd-dev committed Jan 16, 2023
1 parent 8f94cf1 commit 4ad84f7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 176 deletions.
19 changes: 0 additions & 19 deletions src/routes/[slug]/+page.server.js

This file was deleted.

157 changes: 0 additions & 157 deletions src/routes/[slug]/+page.svelte

This file was deleted.

27 changes: 27 additions & 0 deletions src/routes/[slug]/+server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createClient } from '@supabase/supabase-js'
import { SUPABASE_KEY, SUPABASE_URL } from '$env/static/private';
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);

/** @type {import('./$types').RequestHandler} */
export const GET = async ({ params }) => {

const response = await supabase.from('links').select('original_url').eq('short_code', params.slug);

let url = null;
if(response.data){
if(response.data[0])
url = response.data[0].original_url;
}

if(url){
return new Response(undefined, {
status: 302,
headers: { Location: url },
})
}else{
return new Response(undefined, {
status: 302,
headers: { Location: '/' },
})
}
}

1 comment on commit 4ad84f7

@vercel
Copy link

@vercel vercel bot commented on 4ad84f7 Jan 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.