You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following in the footsteps of Next.js' custom server example, I was hoping to implement custom domains (and dynamic subdomains) by writing a custom server and explicitly calling render on a specific path, like so:
server.all('*', (req, res) => {
var hostname = req.headers.host;
// Force go to /user/customdomain if the host is the user's registered domain name or subdomain
if (hostname == 'customdomain.com') {
return app.render(req, res, '/user/customdomain')
}
// Otherwise let the Next.js server handle the request as normal
return handle(req, res)
})
When I try this out and go to customdomain.com in my browser, I get this error:
Unhandled Runtime Error
Error: The provided `as` value (/) is incompatible with the `href` value (/user/[username]).
Read more: https://err.sh/vercel/next.js/incompatible-href-as
The error message makes sense, but I'm left wondering if there's a way to achieve what I want (customdomain.com OR username.mydomain.com => mydomain.com/user/username). I also need this to work with nested routes as well, which I hadn't figured out yet (customdomain.com/page1 => mydomain.com/user/username/page1).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello friends!
Following in the footsteps of Next.js' custom server example, I was hoping to implement custom domains (and dynamic subdomains) by writing a custom server and explicitly calling render on a specific path, like so:
When I try this out and go to
customdomain.com
in my browser, I get this error:The error message makes sense, but I'm left wondering if there's a way to achieve what I want (
customdomain.com
ORusername.mydomain.com
=>mydomain.com/user/username
). I also need this to work with nested routes as well, which I hadn't figured out yet (customdomain.com/page1
=>mydomain.com/user/username/page1
).Any thoughts or ideas? Thanks in advance! ❤️
Beta Was this translation helpful? Give feedback.
All reactions