I'm building an ecommerce platform where users will be using both our domain and their own domains like below.
ourplatform.com/username
theirdomain.com
I'd like to set the inline links depend on the domain they're entering the site. If it's our domain it should be /username/page or if it's their domain it should be just /page.
This is what I have so far. Only adding username if the domain is our platform.
import Link from 'next/link'
const customPath = ({ username }) => {
if (typeof window !== 'undefined') {
return window.location !== 'ourplatform.com'
? '/'
: `/${username}`
}
}
export default ({ username }) => {
const link = customPath({ username })
return (
<Link href={link}>
Home
</Link>
)
}
But I'm getting this error.
Error: Failed prop type: The prop `href` expects a `string` or `object` in `<Link>`, but got `undefined` instead.
How can I set different href links for different domains?