I am trying to store the path into state of my app, so if the user is not logged in and is redirected to `/login` after logging in they can be directed to the correct path.

For example:
Path = `/posts/my-new post`

What I am actually getting is `posts/[pid]` which obvious does not work when I try to redirect to.

```js
import { useRouter } from 'next/router'
import { useState, useEffect } from 'react'

function App() {
  const router = useRouter()
  const [startUrl, setStartUrl] = useState(router.asPath)
  const [loggedIn, setLoggedIn] = useState(false)
  useEffect(() => {
    if (loggedIn) {
      router.push(startUrl)
    }
  },[loggedIn])
  return (
    <>
      <p>Path = {startUrl}</p>
    </>
  )
}
export default App

```