Skip to content

Commit

Permalink
improve error on failed redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
KillariDev committed Jan 29, 2024
1 parent 3c9de63 commit caca77a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/IpfsSubpathRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ export const IpfsSubpathRedirect = () => {
const redirectUrl = generateIpfsSubdomainUrl(hashFromBase)

// redirect to IPFS subdomain url
window.location.href = redirectUrl
try {
window.location.href = redirectUrl
} catch (e) {
console.error(e)
throw new Error(
'Failed to redirect to a safe page. IPFS hosted websites should always be browsed with the content hash in the subdomain, not in the path. This is to protect you, the user, from cache poising attacks.'
)
}
}, [])

return null
Expand Down

0 comments on commit caca77a

Please sign in to comment.