-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- URL's now go directly to the destination
- Loading branch information
Showing
3 changed files
with
27 additions
and
176 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '/' }, | ||
}) | ||
} | ||
} |
4ad84f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
smoll – ./
smoll-drd-dev.vercel.app
smoll-navy.vercel.app
smoll-git-master-drd-dev.vercel.app
smoll.xyz
www.smoll.xyz