title: Setting Dynamic base URL in CodeIgniter 4.0.2
body: <p>I am migrating my project from CodeIgniter 3 to CodeIgniter 4. I am getting confused for the new structure of the framework. So here's my problem, </p>
  
  <p>I am setting my base url in <strong>App.php</strong> to:</p>
  
  <pre><code>protected $proj_root= "http://".$_SERVER['HTTP_HOST'];
  protected $proj_root2  = str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
  protected $mybase= $proj_root.$proj_root2;
  public $baseURL =  $mybase;
  </code></pre>
  
  <p>But I am getting error like this:</p>
  
  <blockquote>
    <p>Fatal error: Constant expression contains invalid operations in D:\xampp\htdocs\delivery_dashboard\app\Config\App.php on line 26</p>
  </blockquote>
  
  <p>So literally I can only do this:</p>
  
  <pre><code>public $baseURL = "http://localhost/my_project/"
  </code></pre>
  
  <p>How can I set my base url dynamically using <code>$_SERVER['HTTP_HOST']</code> or is there any workaround here?</p>
  
  <p>Thanks for the help!</p>