localhost fix

This commit is contained in:
Elijah McMorris 2024-02-16 03:46:00 -08:00
parent ff6ed19606
commit 6fb3d2bdbe
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8

View file

@ -54,7 +54,15 @@ export default function CreateCard() {
const handleCopyUrl = () => { const handleCopyUrl = () => {
if (state && state.url) { if (state && state.url) {
const currentSiteName = window.location.hostname; 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) navigator.clipboard.writeText(url)
.catch(err => { .catch(err => {
console.error('Failed to copy URL to clipboard:', err); console.error('Failed to copy URL to clipboard:', err);