diff --git a/app/api/_utils/textExtraction.ts b/app/api/_utils/textExtraction.ts index a2a3ffb..9adfc9a 100644 --- a/app/api/_utils/textExtraction.ts +++ b/app/api/_utils/textExtraction.ts @@ -43,7 +43,7 @@ export const fetchReadableText = async (url: string): Promise try { const response = await fetch(url, { headers: { - 'User-Agent': 'DumpItBot/1.0 (+https://dumpit-three.vercel.app)', + 'User-Agent': `DumpItBot/1.0 (+${process.env.NEXT_PUBLIC_APP_URL || 'https://dumpit-three.vercel.app'})`, Accept: 'text/html,text/plain;q=0.9,*/*;q=0.1', }, redirect: 'follow', diff --git a/app/components/Profile.tsx b/app/components/Profile.tsx index 7937649..20f63b9 100644 --- a/app/components/Profile.tsx +++ b/app/components/Profile.tsx @@ -23,12 +23,12 @@ export function Profile() { const [shareByDefault, setShareByDefault] = useState(false) const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null) const [copied, setCopied] = useState(false) + const [shareUrl, setShareUrl] = useState('') const handleCopyLink = async () => { - if (!profile?.username) return - const link = `https://dumpit-three.vercel.app/u/${profile.username.toLowerCase()}` + if (!shareUrl) return try { - await navigator.clipboard.writeText(link) + await navigator.clipboard.writeText(shareUrl) setCopied(true) setTimeout(() => setCopied(false), 2000) } catch (err) { @@ -42,6 +42,15 @@ export function Profile() { } }, [user]) + useEffect(() => { + if (profile?.username) { + const origin = typeof window !== 'undefined' ? window.location.origin : (process.env.NEXT_PUBLIC_APP_URL || 'https://dumpit-three.vercel.app') + setShareUrl(`${origin}/u/${profile.username.toLowerCase()}`) + } else { + setShareUrl('') + } + }, [profile]) + const loadProfile = async () => { if (!user) return setLoading(true) @@ -204,8 +213,8 @@ export function Profile() {

Anyone can view your publicly shared resources by visiting your personal link.

-
- https://dumpit-three.vercel.app/u/{profile.username.toLowerCase()} +
+ {shareUrl || `.../u/${profile.username.toLowerCase()}`}