I am using next.js version 13. experimental app directory, which does not have access to getServerSideProps()
Pages in the "app" directory are server side by default.
Inside page.js, I am trying to get the url of the current page.
How would I do that?
export default async function myPage(props) {
const prot = // HTTP or HTTPS
const domain = //www.myserver.com
const port = //3000
... and so on.
}
I saw this solution: Get URL pathname in nextjs
But 'next\router' that doesn't work on server components.
I get this error when compiling: You have a Server Component that imports next/router. Use next/navigation instead.