Support Forums

Hosting SPA on subdomains

Need to host an Angular SPA. The app will be hosted via wild card subdomains. We need sandbox and prod.

Sandbox will run for eg on *.sbox.domain.com and prod on *.domain.com. Each client who signs up gets a domain on both. For eg. client1.sbox.domain.com and client1.domain.com. Similarly other clients will get their own subdomains.

All subdomains on sbox will display the same app and similarly all subdomains on domain.com will display a different version (stable) of the same app. The app should be served via the same url and should not redirect

We are happy to delegate dns to net lift.

Is this possible with thePro account? Any caveats?

We can enable Wildcard subdomains for an account, but here’s some stuff to keep in mind.

There are a few requirements before we’re able to do so:

  1. Either you have to use Netlify DNS so we can get you a wildcard SSL cert, or you must bring a custom wildcard certificate.
  2. We can only do this for a site that’s on a paid team (see Netlify Pricing and Plans for details)

Also note:

  • You can’t use domain aliases on the site with Wildcard subdomains enabled, just the bare domain and subdomains under your primary domain. If you try to add a domain alias then it won’t work.
  • The primary custom domain for the site, if it is a “site.com+www.site.com” setting in our UI, must be www.site.com and NOT site.com!

Once the wildcard subdomain feature is enabled, you do not need to add new subdomains under the site settings. You’ll will need still need to create DNS records.

This might be a single wildcard DNS record for all subdomains (like a CNAME for *.example.com pointing to the netlify.app subdomain for the site). Alternatively, you can also create the individual DNS records to add each subdomain (like CNAMEs for subdomain-a.example.com , subdomain-b.example.com , etc.) as covered in our external DNS documentation. Both work so please do whichever you prefer.

Please also be aware that we do not current have any built-in method of doing server side “domain-specific” handling - for instance if you want a redirect to automatically redirect from x.yourdomain.com to a path of x based on that subdomain, you’ll have to do that in client-side JS (you can make hostname-specific redirects, but those require the full hostname to be input into each rule, which defeats the zero-config nature of this feature), so please share your use case with us if you are worried about any of the limitations above so you don’t spend time implementing to this feature only to discover limitations that block your use.