rsnext/test/integration/fallback-false-rewrite/pages/[slug].js
JJ Kasper 7d77a19af2
Fix fallback: false triggering 404 before rewrites (#24121)
This fixes dynamic pages with `fallback: false` that don't have a matching path causing a 404 before rewrites are checked unexpectedly. This ensures we treat `fallback: false` pages as a match only if they also have a matching static path so that fallback rewrites can be triggered correctly. An additional test suite as been added to ensure this is working as expected. 

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
2021-04-16 15:07:24 +00:00

31 lines
526 B
JavaScript

import { useRouter } from 'next/router'
export const getStaticProps = () => {
return {
props: {
world: 'world',
},
}
}
export const getStaticPaths = () => {
return {
paths: ['/first', '/second'],
fallback: false,
}
}
export default function Page({ world }) {
const router = useRouter()
if (router.isFallback) {
throw new Error('should not have fallback')
}
return (
<>
<p id="slug">hello {world}</p>
<p id="query">{JSON.stringify(router.query)}</p>
</>
)
}