Questions about multi-tenant setup

Hi! I am considering moving from Vercel to Netlify because it looks like you have better support for multi-tenant apps. Reading other threads on wildcard subdomains, I know that it needs to be a Pro+ team account.

Appreciate it if you could help with my questions before migration.

Question 1:
Assuming my primary domain is I can only use * for wildcard subdomains and it is not possible to have * Is that correct?

I already have some other subdomains in use. They are set up using CNAME records. For example has a CNAME to my Firebase auth, or has a CNAME to sendgrid.
My understanding is that I need to add either a CNAME with * to my Netlify site address or I can add CNAMEs for subdomains individually (like a CNAME for and another CNAME for both pointing to my Netlify site address.).

To be clear let me ask my question with an example. Assuming there are these 2 DNS records on my domain ( They are used to set wildcard subdomains, and also to set custom auth service:

  • CNAME: * →
  • CNAME: auth → custom.auth.provider

Am I correct to assume that if you go to, the request will go to custom.auth.provider? I am assuming that the specific value (auth in this case) will take precedence on the wildcard (*).

Question 3:
As for the multi-tenant app. The app is build using Nuxtjs. Each user gets a path (/profile/<username>). After setting up the wildcard subdomains, I want to rewrite https://<username>* with<username>/*. Is that something that can be achieved using netlify.toml or you suggest an edge function for it?

Thanks a lot for your time.

Technically, you’d need to have the domain or basically <anything> for * to work on that site. But yes, you can’t have * on the same site, you can do that on a different one.

Yes, and that has nothing to do with Netlify, but that’s just have DNS will work. Specific entries will take preference over wildcards.

You’d have to use Edge Functions or even a middleware in Nuxt would work. Nuxt can be deployed to Edge Functions, so no need to write a separate Edge Function just to handle this redirect, unless you need Nuxt to be deployed to AWS Lambda due to whatever reason.

Thank you @hrishikesh for taking the time and for your helpful answer :slight_smile:

On the 3rd question, my requirement is to rewrite (not redirect) <username> to<username>, to be clear, when a user goes to* the URL won’t change but the served response will the same as*. That way each user can set a CNAME on their domain pointing to our subdomain in order to have their profile and subpaths under their domain.

For example: when you go to, while your browser url is showing you will see the contents that is also available at

Hope it makes sense and looks like it is possible to achieve with Netlify.

What I appreciate help with is understanding what the Edge Function workflow would look like.

I understand that a rewrite is possible. And I also understand that rewrite is the same as a redirect but with status code 200. Is there an example of how to setup with rewrite from subdomain to path using edge functions?

Looks like my question is very similar to this one, I hope things have changed since 2021.

Untested, but something like this:

export default async (req : Request) => {
  const reqUrl = new URL(req.url)
  return new URL(`/profile/${reqUrl.hostname.split('.')[0]}/${reqUrl.pathname}`, '')

should work for a URL like: that needs to be rewritten to This would further take into account the path on the original URL, for example: would now be rewrriten to This would not work as intended for due to the www in the hostname. It would require some special handling.

1 Like

That’s a great response @hrishikesh. I know have a better understanding.

Now my next quest is to find out how to return a URL as the response using a Nitro middleware (Nuxt server middleware). My idea is to have a Nuxt server middleware (~/server/middleware/subdomain.ts). This middleware will be executed whenever a request hits any server route. In side I can do the checks and send the new URL.

The thing is I don’t know how to do that at the moment.

Ah! scratch that!

Nuxt server middlewares are not supposed to return a response.

Middleware handlers should not return anything (nor close or respond to the request) and only inspect or extend the request context or throw an error.

So, that’s not possible with a Nuxt middleware to check if the request is coming from a subdomain and rewrite it to a path.

Using a Netlify Edge function looks pretty straightforward though. I think I just need to add a function that runs on every request to server, checks the request host, and if it is a subdomain, rewrite it to a path, by returning a new URL. Is that right?

I don’t know how to do that in Nuxt, though.

Yeah it appers that Nuxt doesn’t really support rewrites. You would have to rely on native Netlify Edge Functions then.