firebasefirebase-hostinga-records

How can different subdomains point to the same IP and reach different webpages?


I have a firebase project with 2 web applications:

name:      url
PC         pc-my-app.web.app
Mobile     m-my-app.web.app

firebase gives me the IP X.X.X.X for both applications.

I have a domain, example.com with the following records:

 A     example.com X.X.X.X
 A   m.example.com X.X.X.X

I thought that having these records pointing to the same IP would mean I see the same webpage, but that is clearly not the case.

Since ports are (apparently) never specified, how can the server on X.X.X.X tell which application I am trying to connect to?

My guess is that the server on X.X.X.X also recieves the original URL as a parameter somehow...


Solution

  • Firebase Hosting (and most other hosting providers) check the Host header in the incoming request to determine what content to serve. And this Host header value allows a single server to map different requests to the correct web site content (often referred to as a "virtual host").

    Also see: