Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Corrected getConfig()
  • Loading branch information
samestrin committed May 15, 2024
commit 6e5ddbb52d7fe56f94c5a7fb7e820db45fd5db7a
2 changes: 1 addition & 1 deletion netlify/edge-functions/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { config } from "https://deno.land/x/dotenv@v3.2.2/mod.ts";

function getConfig() {
export function getConfig() {
const env = config();

return {
Expand Down
6 changes: 3 additions & 3 deletions netlify/edge-functions/redirect.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import handler from "./utils.ts";
const { fetchFromSupabase, logClick, validateIpAddress } = handler();
import { getConfig } from "./config.ts";
const { URLSHORT_TRACK_CLICKS } = getConfig();

const { URLSHORT_TRACK_CLICKS, URLSHORT_RESOLVE_HOSTNAME } = getConfig();
console.log({ URLSHORT_TRACK_CLICKS, URLSHORT_RESOLVE_HOSTNAME });
/**
* Handles redirection for shortened URLs, logs the click, IP address, and hostname.
*
Expand Down Expand Up @@ -41,7 +41,7 @@ export default async (
let ipAddress = ip || request.headers.get("x-forwarded-for") || "";

let hostname = "";
if (validateIpAddress(ipAddress)) {
if (URLSHORT_RESOLVE_HOSTNAME && validateIpAddress(ipAddress)) {
try {
hostname = await getHostnameFromIp(ipAddress);
} catch (error) {
Expand Down
1 change: 0 additions & 1 deletion netlify/edge-functions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getConfig } from "./config.ts";

const { SUPABASE_URL, SUPABASE_ANON_KEY } = getConfig();

/**
Expand Down