Multiple domains with single deployed app?

I am trying to figure how to handle multiple domains with the same app

Say I have a “” and “” they are getting rendered by the same app, however each of them have their own look and data. (Domain1 is pink but Domain2 is green, …)
The app renders based on some properties from DB and looks different on each domain

I’ve searched and found some old posts but they dont make it clear if what I want to do is possible??


1 Like

Hi @mobayen :wave:t6: ,

Welcome to the forums and thanks so much for reaching out! Yep, this is possible you can setup a redirect to different subdomains. Heres a support guide that dives a bit deeper in how to accomplish this.

Thanks for the response
I dont want to redirect domains! The visitors suppose to stay in the original domain.

it is what I am trying to do:
1- visitors hit the
2- my application pulls data specific for the
3- and then the app gets rendered based on the data
again, the visitor stays in the

Thanks again

@mobayen What you want to do is possible and could be achieved multiple ways.

In a Jamstack fashion one way you could do it would be with a single shared codebase that is configured as two (or more) sites and when the build is executed it outputs a different result based on knowing which site it should generate (which it could determine via an environment variable, or build flag, or unique site id etc).

If you’re talking about a heavily JavaScript based web app, then it could also be achieved at runtime by identifying the domain it’s executing under and applying or otherwise pointing at a different set of styles.

Thanks Nathan
Actually I am trying to identify the domain at runtime (server side). It is what I am trying to figure out.

How I can identify the “domain” app is executing under?

I tried the “hostname” but what i get is “localhost” all the time

@mobayen Can you provide some more detail on what you mean by “at runtime (server side)”?

If you’re working in a Jamstack fashion there is no traditional “server side”.

There is the “build” which is performed, and then the resulting files which are deployed to CDN.

Even if you’re using Serverless Functions they’re executing elsewhere as they’re AWS Lambda’s.

@nathanmartin I dont think it count as a jamstack. I am developing a Vue/NuxtJs app. so it is an SSR app.
That means I need the domain-name/hostname on the Serverside to be able render the website properly
Normally it would be done like event.req.hostname, however it returns “localhost” regardless what is the real-hostname

@mobayen I believe it is still Jamstack.

Unless I’m mistaken, the SSR is performed by Serverless Functions.

@nathanmartin thanks

No “serverless functions” is needed, Netlify handles SSR. However, it;s not easy to get the hostname on the server side!!

@mobayen, I understand that you’re not manually creating your own Serverless Functions, but the reality is that the “SSR” is almost certainly executing as such.

Read the following:

Environment Variables are available to Functions, so you might want to give that a try.

1 Like

I figured it out!
I am using Nuxt3 and here it is how I fixed it:

A startUp.server.ts which is a server side only pllugin

export default defineNuxtPlugin(async (nuxtApp) => {
  let hostName = nuxtApp.ssrContext? ?? 'no-hostname'

Great work.

What I said originally applies…

Lots of ways to get it done, glad you found one that you’re happy with.

Hi @mobayen :wave:t6: thanks so much for coming back and sharing your specific solution. We appreciate the feedback and I hope it helps others who experience a similar problem.