Skip to content

Commit

Permalink
add OVERRIDE_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
NexVeridian committed Jun 4, 2024
1 parent 3965a31 commit cbd5492
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ POSTGRES_DB=url
# surrealdb
DB_USER=root
DB_PASSWORD=root
OVERRIDE_URL=s.nexv.dev
```

# License
Expand Down
12 changes: 1 addition & 11 deletions src/app/create/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,7 @@ export default function CreateCard() {

const handleCopyUrl = () => {
if (state && state.url) {
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()}`;
} else {
url = `https://${currentSiteName}/${state.url.toString()}`;
}

navigator.clipboard.writeText(url)
navigator.clipboard.writeText(state.url)
.catch(err => {
console.error('Failed to copy URL to clipboard:', err);
});
Expand Down
11 changes: 11 additions & 0 deletions src/app/create/db.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,19 @@ export async function querydb(prevState: any, formData: FormData) {

url = url[0].id;
}

console.log(url);

const currentSiteName = process.env.OVERRIDE_URL !== undefined ?
process.env.OVERRIDE_URL : window.location.hostname;

if (currentSiteName === "localhost" || currentSiteName === "0.0.0.0") {
const currentPort = window.location.port;
url = `http://${currentSiteName}:${currentPort}/${url.toString()}`;
} else {
url = `https://${currentSiteName}/${url.toString()}`;
}

return { url: url };
} catch (e) {
return;
Expand Down

0 comments on commit cbd5492

Please sign in to comment.