Skip to content

Commit

Permalink
display correct missing route in 404 page (#2083)
Browse files Browse the repository at this point in the history
## What's the purpose of this pull request?

display the correct missing URL when hitting a 404 page
#2064

## How it works?

use `asPath` which Next provides as the alias for that particular 404
response

## How to test it?

1. visit path which doesn't exist
2. see that the URL is displayed in the body of the page

### Starters Deploy Preview

<!--- Add a link to a deploy preview from `gatsby.store` AND
`nextjs.store` with this branch being used. --->

<!--- Tip: You can get an installable version of this branch from the
CodeSandbox generated when this PR is created. --->

## References

<!--- Spread the knowledge: is there any content you used to create this
PR that is worth sharing? --->

<!--- Extra tip: adding references to related issues or mentioning
people important to this PR may be good for the documentation and
reviewing process --->
  • Loading branch information
batzlerg authored Oct 30, 2023
1 parent a451b29 commit 1efa0ef
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/core/src/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import EmptyState from 'src/components/sections/EmptyState'

const useErrorState = () => {
const router = useRouter()
const { from } = router.query
const { pathname } = router
const { pathname, asPath } = router

return {
fromUrl: from ?? pathname,
fromUrl: asPath ?? pathname,
}
}

Expand Down

1 comment on commit 1efa0ef

@vercel
Copy link

@vercel vercel bot commented on 1efa0ef Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.