Dynamic Url APP_URL

hello @johnny
I have an application that uses Grocery CRUD.

My application is placed in a folder under the Apache document root. The Apache document root can be accessed with multiple domain names using aliases, for example:

  1. example1.com
  2. example2.com
  3. example3.com

I noticed that Grocery CRUD heavily depends on the APP_URL configuration in the .env file. What should I do to make my Grocery CRUD accessible from these different domains?

My goal for this setup is that each domain uses different data. For instance, in a table (e.g., page table), there is a field called domain_id.

  • example1.com will display data in the page table where the domain_id field equals 1.
  • example2.com will display data where the domain_id field equals 2, and so on.

regards
Nasrul

hello @johnny
After debugging Grocery CRUD, I found a solution to the problem. It works now, but I’m unsure of the potential impact.

To solve the issue, I added the following line before creating the Grocery CRUD instance:

$database = $this->_getDatabaseConnection();
$config = config(‘grocerycrud’);
$config[‘assets_folder’] = request()->getSchemeAndHttpHost() . “/vendor/grocery-crud/”;
$crud = new GroceryCrud($config, $database);

regards
Nasrul

Hello @nasrul ,

Yes this is the correct approach that you took :slight_smile:

Regards
Johnny