(talking about /pages) The 404.tsx file behaves differently than most pages in the file router, in that it renders the 404 page, but does not change the URL.
I am trying to implement similar behavior, for RBAC related purposes. E.g. the user receives a generic "you cannot access this page" but the URL stays the same.
I tried actually using the 404 page for this purpose, where (in getServerSideProps) I {notFound:true} the request if it's truly not found OR they don't have access. And then on the client, I determine whether to show a true 404 or a "no access page".
This was working until removal of getInitialProps in _app caused the 404 page to be statically generated, and now useRouter yields an empty query object, which I was previously using to determine whether to show a 404 or no access page.
SO, Is there a way for me to send users to a "no access page", but preserve the URL that they originally accessed? I.e. I don't want to redirect them to /no-access, I want them to stay on /:teamId/admin but be shown a no-access page.