'Concept of a SaaS system

Good evening, I developed a system that behaves in the SaaS format, where the client only registers and already has access to use, in it I used a unique identifier for each client and they all use the same structure, PHP files and the same database . So far so good, because the domain does not change, that is, everyone uses www.lalalaetc.com.br/app and the system separates everything by the unique identifier, however, I would like to develop a virtual store from it, only there would be a difference, the domain, that is, I believe the principle is the same, use a unique identifier for each store, but my doubt is how I will make it so that when someone accesses the store the domain is addressed correctly and load the id of my client? What is the way forward and what do I need to research to do such a feat?



Solution 1:[1]

i managed to handle the tenant with the folomming steps:

  1. i cloned de the parse server source and i added a new middleware named "tenantConfig"
  2. in that middleware i intercepts the requests and i get one specific header that i named "x-parse-tenant" and i use the value of that header like a database name
  3. so i modify the datapase adapter and then resent it to the requetes and do next() to continue the process
  4. so in the client lib or the requests i provide a "x-parse-tenant" header

you can see details in the screenshots its not perfect i know :D

enter image description here enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 okobsamoht