-
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
Handle assets-path correctly #362
base: main
Are you sure you want to change the base?
Conversation
couldn't you instead avoid the 500 by returning null (instead of throwing Error) and call |
This does not solve the root cause. We normally get the domain from the host (in the middleware) and use it later as domain param. So we can rely on the param to be correct. However, in this special case we skip the middleware so that we have to execute host matching code on a later stage. Additionally, |
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.
It's odd that this needs to be done in getSiteConfigForDomain, but I can't think of a better solution. We could try to get rid of the assets folder altogether, as we discussed in #283 (comment).
@@ -9,7 +9,13 @@ export function getHostByHeaders(headers: Headers) { | |||
} | |||
|
|||
export function getSiteConfigForDomain(domain: string) { | |||
const siteConfig = getSiteConfigs().find((siteConfig) => siteConfig.scope.domain === domain); | |||
let siteConfig; | |||
if (domain === "assets") { |
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.
We should add a comment here explaining why this if is needed.
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.
If an assets-path to a file that does not exist in the public-folder is called (e.g. /assets/foo) then next tries to render this request and routes to page.tsx. The problem is that the rewrites in the middleware are not executed and "assets" is used as domain-parameter leading to a 500 (instead a desired 404).
This PR handles the assets-path and gets the site-config via the headers so that the 404-page can be rendered.