From 6fb3d2bdbe5a63bc55d3534564e26e55f9a1946b Mon Sep 17 00:00:00 2001 From: NexVeridian Date: Fri, 16 Feb 2024 03:46:00 -0800 Subject: [PATCH] localhost fix --- src/app/create/create.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/create/create.tsx b/src/app/create/create.tsx index fa13ae8..da6dad3 100644 --- a/src/app/create/create.tsx +++ b/src/app/create/create.tsx @@ -54,7 +54,15 @@ export default function CreateCard() { const handleCopyUrl = () => { if (state && state.url) { const currentSiteName = window.location.hostname; - const url = `https://${currentSiteName}/${state.url.toString()}`; + + let url = undefined; + if (currentSiteName === "localhost" || currentSiteName === "0.0.0.0") { + const currentPort = window.location.port; + url = `http://${currentSiteName}:${currentPort}/${state.url.toString()}`; + } else { + url = `https://${currentSiteName}/${state.url.toString()}`; + } + navigator.clipboard.writeText(url) .catch(err => { console.error('Failed to copy URL to clipboard:', err);