67482914c6
This interpolates the dynamic values and rebuilds the request URL for fallback SSG pages since the proxy uses the output path for non-prerendered pages on Vercel which can cause inconsistent request URL/`asPath` values for SSG pages. This also adds tests to ensure the `asPath` is correctly updated Fixes: https://github.com/vercel/next.js/issues/16269
30 lines
533 B
JavaScript
30 lines
533 B
JavaScript
import { useRouter } from 'next/router'
|
|
|
|
export default function Comment({ params }) {
|
|
const router = useRouter()
|
|
|
|
if (router.isFallback) return 'Loading...'
|
|
|
|
return (
|
|
<>
|
|
<p id="as-path">{router.asPath}</p>
|
|
<p id="query">{JSON.stringify(router.query)}</p>
|
|
<p id="params">{JSON.stringify(params)}</p>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const getStaticProps = ({ params }) => {
|
|
return {
|
|
props: {
|
|
params,
|
|
},
|
|
}
|
|
}
|
|
|
|
export const getStaticPaths = () => {
|
|
return {
|
|
paths: [],
|
|
fallback: true,
|
|
}
|
|
}
|