Hello,
I am using Firebase for a service used by multiple customers.
My service allows customers to create a project and then to list public information for this project at an URL that includes the project ID as HTTP parameter.
Firebase hosting is configured to use a custom domain:
mydomain.com.
The response is created by a Firebase HTTP function based on the project ID.
Hosting requests to /project redirect to a Cloud Function using a rewrite.
The project ID is deduced from the customer domain or subdomain used.
I wonder if the current Firebase features and Cloud functions allow such kind of reverse proxy use case. I really like the possibility to control CDN caching from Cloud functions.
Before asking on this group I made a few tests. Currently, I am facing 2 issues for achieving what I would like to do:
1) How to retrieve the original request domain from a Cloud function?
I tried the following:
exports.test = functions.https.onRequest((req, res) => {
const host = req.get('host');
const origin = req.get('origin');
console.log('host=' + host);
console.log('origin=' + origin);
res.send(200, {
'host': host,
'origin': origin,
});
});
2) Firebase hosting allows connecting multiple domains. However, is there a limit on the number of domains? More importantly, is there an API to automate the creation of such connections?
Any ideas and suggestions are welcome.
Kind Regards,
Laurent Pellegrino