I can get the relative pathname using useRouter().asPath
which gives something like /my-awesome-post
but how to get the origin?
Similar to what window.location.origin
gives like https://www.google.com
.
Next.js Router docs doesn't mention anything about how to get origin.
I can't use window.location.origin
(next.js gives an error that window is not defined) so what is my alternative?
I want to get the origin inside a component which is not calling getStaticProps
or getServerSideProps
.