-
Notifications
You must be signed in to change notification settings - Fork 0
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
Present 404 when domain lookup not successful #705
base: main
Are you sure you want to change the base?
Conversation
site/src/app/not-found.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? We could also use Next' built-in 404 for this special case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or at least add some default text (in english)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we use a rewrite to avoid having to render a root layout: 03b2062
So the "normal" 404 is shown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting technique
but now you need to hardcode a default domain and language in the middleware.... i'm not sure if that is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware that this is not the best solution. The simpler solution which rewrites just to /
however makes it somewhat complicated...
This requires a app/layout.tsx
, but app/domain/language/layout.tsx
renders the <html>
tag exclusively (because of the lang
-attribute). Since the layouts are merged, app/layout.tsx
can then only contain <>{children}</>
whilst app/not-found.tsx
must then render a separate <html>
-Tag. This is just confusing, so I decided for this simple approach.
Moreover, this is not the only place to hardcode these values: https://github.com/vivid-planet/comet-starter/blob/main/site/src/app/%5Bdomain%5D/%5Blanguage%5D/not-found.tsx#L11 (even though this won't be used during runtime).
In my opinion the root cause should be solved by Next.js: vercel/next.js#49415
Implements vivid-planet/comet#3300
Shows an empty page as this 404 is just a fallback for missing configurations.