From 2d2a4a4c0707447475198d09ce16cfd3309c2c54 Mon Sep 17 00:00:00 2001 From: NexVeridian Date: Mon, 3 Jun 2024 16:45:04 -0700 Subject: [PATCH] add OVERRIDE_URL --- README.md | 2 ++ src/app/create/create.tsx | 13 ++++++++----- src/app/create/db.tsx | 5 +++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e8bff19..59f72c4 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ POSTGRES_DB=url # surrealdb DB_USER=root DB_PASSWORD=root + +OVERRIDE_URL=s.nexv.dev ``` # License diff --git a/src/app/create/create.tsx b/src/app/create/create.tsx index 0391ce4..6dee546 100644 --- a/src/app/create/create.tsx +++ b/src/app/create/create.tsx @@ -46,14 +46,17 @@ export default function CreateCard() { const handleCopyUrl = () => { if (state && state.url) { + let url = undefined; const currentSiteName = window.location.hostname; - let url = undefined; - if (currentSiteName === "localhost" || currentSiteName === "0.0.0.0") { - const currentPort = window.location.port; - url = `http://${currentSiteName}:${currentPort}/${state.url.toString()}`; + if (state.url.includes("https://")) { + url = state.url; } else { - url = `https://${currentSiteName}/${state.url.toString()}`; + if (currentSiteName === "localhost" || currentSiteName === "0.0.0.0") { + url = `http://${currentSiteName}:${window.location.port}/${state.url.toString()}`; + } else { + url = `https://${currentSiteName}/${state.url.toString()}`; + } } navigator.clipboard.writeText(url) diff --git a/src/app/create/db.tsx b/src/app/create/db.tsx index 502333c..0266700 100644 --- a/src/app/create/db.tsx +++ b/src/app/create/db.tsx @@ -64,8 +64,13 @@ export async function querydb(prevState: any, formData: FormData) { url = url[0].id; } + console.log(url); + if (process.env.OVERRIDE_URL !== undefined) { + url = `https://${process.env.OVERRIDE_URL}/${url.toString()}`; + } + return { url: url }; } catch (e) { return;