Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fraxachun
Copy link
Contributor

Implements vivid-planet/comet#3300

Shows an empty page as this 404 is just a fallback for missing configurations.

Copy link
Collaborator

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

Copy link
Member

@nsams nsams Jan 30, 2025

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)

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

@fraxachun fraxachun Jan 31, 2025

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

manuelblum
manuelblum previously approved these changes Jan 30, 2025
nsams
nsams previously approved these changes Jan 30, 2025
@fraxachun fraxachun dismissed stale reviews from nsams and manuelblum via 03b2062 January 31, 2025 09:51
@fraxachun fraxachun requested a review from johnnyomair January 31, 2025 09:52
@fraxachun fraxachun added the recommended-change Change should be added to existing projects and be mentioned in the next migration guide label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recommended-change Change should be added to existing projects and be mentioned in the next migration guide
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants