-
Notifications
You must be signed in to change notification settings - Fork 27.7k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot have an _error.tsx file without a 404.tsx file #12256
Comments
Same as #12246 |
Replied here: #11945 (reply in thread) |
What you're looking for seems to be #9081
What we can do is improve the error message / documentation around it. |
Thank you for the replies! What isn’t clear to me though is whether the redirects feature is already available in the latest version of Next.js as it was still marked as open. Also, is it possible to create a redirect with a regex-based src key so that I can redirect all routes with a trailing slash? This issue is unfortunately holding up the launch our website... |
I was, however, able to solve it by changing the
That works well. |
Shouldn't be this up to the developer to decide? Feels like being too babysitted here. In our case we would like to serve different 404 pages depending on the language. Now I'm forced to use a useEffect inside the 404 page to trigger the language change, which shows a flash of the English version. |
Has this possibly been fixed? I've just tested next with just |
nvm, this bug is still present. |
Yeah this seems confusing. I followed the steps detailed in the Sentry docs, which makes no mention of also requiring a However, this is contradicted in the Next example with Sentry. Intuitively, it makes sense I can either have a specific 404 page, or a general error page. As it stands, it's not clear why both are required, what the dependency is between them, or what the logic is to determine which one to show. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Bug report
Describe the bug
It isn't possible to have an
_error.tsx
file in the/pages
folder without also having a404.tsx
file. When runningnext dev
, it works fine, but as soon as you runnext build
, the following error appears:According to the official Next.js Blog, it should not be a problem to have a
_error.tsx
without a404.tsx
: https://nextjs.org/blog/next-9-3#automatic-static-optimization-for-404The reason I do not want a static 404 page is so that I can catch routes with a trailing slash and redirect accordingly to the route without a trailing slash. This must be done on the server.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
_error.tsx
file with agetServerSideProps()
function.next build
.Expected behavior
The error message says that it is trying to export the
_error.tsx
file even though it obviously shouldn't be. The application should still build. As soon as I add a404.tsx
file or remove the_error.tsx
file, it builds without a problem.System information
Additional context
Just in case it might be of any use, here is the code from my
_error.tsx
file:The text was updated successfully, but these errors were encountered: