94a5bd6109
This normalizes the `asPath` for `getServerSideProps` and `getStaticProps` pages to ensure it matches the value that would show on the client instead of a) the output pathname when revalidating or generating a fallback or b) the `_next/data` URL on client transition. Fixes: https://github.com/vercel/next.js/issues/16542
21 lines
326 B
JavaScript
21 lines
326 B
JavaScript
import { useRouter } from 'next/router'
|
|
|
|
export default function Index() {
|
|
const router = useRouter()
|
|
|
|
return (
|
|
<>
|
|
<p id="as-path">{router.asPath}</p>
|
|
<p id="index">index</p>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const getStaticProps = () => {
|
|
return {
|
|
props: {
|
|
hello: 'world',
|
|
},
|
|
revalidate: 1,
|
|
}
|
|
}
|