Search code examples
firebasednssingle-page-applicationfirebase-hostingwebflow

Separate hosting for SPA and Website but share domain


I want to separate hosting of my app and website. The hierarchy is as follows:

  • example.com - website hosted at DigitalOcean
  • example.com/* - SPA hosted at Firebase Hosting

Since DNS does not allow to point the subdirectories, is there any wiser way, to accomplish this?

Thanks in advance!


Solution

  • As the subdomain solution isn't favored, you could try a proxy like nginx to route traffic based on the path to different backends. An example configuration might look something like this:

    server {
        listen       ...;
        ...
        location / {
            proxy_pass http://<your-website>;
        }
    
        location /app {
            proxy_pass http://<your-app>;
        }
    
        location /another-app {
            proxy_pass http://<another-app>;
        }
        ...
    }
    

    Source: https://gist.github.com/soheilhy/8b94347ff8336d971ad0

    You may also want to check whether the Digital Ocean load balancer product offers path based routing.