Issue with Base URL Configuration in CodeIgniter Using Laragon - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Issue with Base URL Configuration in CodeIgniter Using Laragon (/showthread.php?tid=88674) |
Issue with Base URL Configuration in CodeIgniter Using Laragon - tarcisiodev1 - 10-16-2023 I'm having an issue with the CodeIgniter routing system, especially when I modify the base URL, which becomes necessary when I'm using Laragon as the server with Apache since it sets up a specific URL. Here's the scenario: Scenario without changing app.baseURL: app.baseURL = '' In this case, everything works correctly even if I use a different URL than the one set by Laragon, for example: http://codeigniter.test/ Scenario with a change in app.baseURL: app.baseURL = 'http://codeigniter.test/' When I change the base URL to the one used by Laragon (http://codeigniter.test/), an error occurs. What could be causing this issue? Note: Previous versions of CodeIgniter do not have this error. I use version 4.4.1 esse erro: Code: Fatal error: Uncaught CodeIgniter\Exceptions\ConfigException: Config\App::$baseURL is invalid. in C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\HTTP\SiteURI.php:197 Stack trace: #0 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\HTTP\SiteURI.php(143): CodeIgniter\HTTP\SiteURI->normalizeBaseURL(Object(Config\App)) #1 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\HTTP\SiteURI.php(98): CodeIgniter\HTTP\SiteURI->determineBaseURL(Object(Config\App), NULL, NULL) #2 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\HTTP\SiteURIFactory.php(222): CodeIgniter\HTTP\SiteURI->__construct(Object(Config\App), '/', NULL) #3 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\HTTP\SiteURIFactory.php(43): CodeIgniter\HTTP\SiteURIFactory->createURIFromRoutePath('/') #4 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\Services.php(798): CodeIgniter\HTTP\SiteURIFactory->createFromGlobals() #5 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\BaseService.php(258): CodeIgniter\Config\Services::uri(NULL, false) #6 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\BaseService.php(199): CodeIgniter\Config\BaseService::__callStatic('uri', Array) #7 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\Services.php(791): CodeIgniter\Config\BaseService::getSharedInstance('uri', NULL) #8 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\BaseService.php(258): CodeIgniter\Config\Services::uri() #9 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\Services.php(565): CodeIgniter\Config\BaseService::__callStatic('uri', Array) #10 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\Services.php(523): CodeIgniter\Config\Services::incomingrequest(Object(Config\App), false) #11 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\BaseService.php(258): CodeIgniter\Config\Services::request(NULL, false) #12 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\BaseService.php(199): CodeIgniter\Config\BaseService::__callStatic('request', Array) #13 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\Services.php(519): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL) #14 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Config\BaseService.php(258): CodeIgniter\Config\Services::request() #15 C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\Debug\Exceptions.php(135): CodeIgniter\Config\BaseService::__callStatic('request', Array) #16 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(CodeIgniter\Exceptions\ConfigException)) #17 {main} thrown in C:\laragon\www\teste_test\vendor\codeigniter4\framework\system\HTTP\SiteURI.php on line 197 RE: Issue with Base URL Configuration in CodeIgniter Using Laragon - kenjis - 10-16-2023 The error message shows the baseURL is invalid as a URL. But http://codeigniter.test/ seems to be valid. Change the following code, and show the error message. Code: --- a/system/HTTP/SiteURI.php RE: Issue with Base URL Configuration in CodeIgniter Using Laragon - tarcisiodev1 - 10-16-2023 (10-16-2023, 06:34 PM)kenjis Wrote: The error message shows the baseURL is invalid as a URL. I made the modifications and got this: Code: Fatal error: Uncaught CodeIgniter\Exceptions\ConfigException: Config\App::$baseURL is invalid: http://pas_backend.test/ in C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\HTTP\SiteURI.php:197 Stack trace: #0 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\HTTP\SiteURI.php(143): CodeIgniter\HTTP\SiteURI->normalizeBaseURL(Object(Config\App)) #1 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\HTTP\SiteURI.php(98): CodeIgniter\HTTP\SiteURI->determineBaseURL(Object(Config\App), NULL, NULL) #2 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\HTTP\SiteURIFactory.php(222): CodeIgniter\HTTP\SiteURI->__construct(Object(Config\App), '/', NULL) #3 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\HTTP\SiteURIFactory.php(43): CodeIgniter\HTTP\SiteURIFactory->createURIFromRoutePath('/') #4 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\Services.php(798): CodeIgniter\HTTP\SiteURIFactory->createFromGlobals() #5 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\BaseService.php(258): CodeIgniter\Config\Services::uri(NULL, false) #6 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\BaseService.php(199): CodeIgniter\Config\BaseService::__callStatic('uri', Array) #7 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\Services.php(791): CodeIgniter\Config\BaseService::getSharedInstance('uri', NULL) #8 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\BaseService.php(258): CodeIgniter\Config\Services::uri() #9 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\Services.php(565): CodeIgniter\Config\BaseService::__callStatic('uri', Array) #10 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\Services.php(523): CodeIgniter\Config\Services::incomingrequest(Object(Config\App), false) #11 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\BaseService.php(258): CodeIgniter\Config\Services::request(NULL, false) #12 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\BaseService.php(199): CodeIgniter\Config\BaseService::__callStatic('request', Array) #13 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\Services.php(519): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL) #14 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Config\BaseService.php(258): CodeIgniter\Config\Services::request() #15 C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\Debug\Exceptions.php(135): CodeIgniter\Config\BaseService::__callStatic('request', Array) #16 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(CodeIgniter\Exceptions\ConfigException)) #17 {main} thrown in C:\laragon\www\pas_backend\vendor\codeigniter4\framework\system\HTTP\SiteURI.php on line 197 Note: The name of the project/URL I'm using is http://pas_backend.test/. 'codeigniter.test' was an example, but I downloaded in another project and got the same result, as in the previous error example, which was teste_test.test. RE: Issue with Base URL Configuration in CodeIgniter Using Laragon - kenjis - 10-16-2023 http://pas_backend.test/ or pas_backend.test is invalid. Do not use `_` in domain names. RE: Issue with Base URL Configuration in CodeIgniter Using Laragon - tarcisiodev1 - 10-16-2023 (10-16-2023, 09:11 PM)kenjis Wrote: http://pas_backend.test/ or pas_backend.test is invalid. Is this a new configuration in CodeIgniter? Because I use projects with older versions (4.36) and it works fine. It's just in this project that, somehow, I'm not able to make it work RE: Issue with Base URL Configuration in CodeIgniter Using Laragon - kenjis - 10-16-2023 Yes. The previous versions did not validate the baseURL. Now it is validated as a correct URL. RE: Issue with Base URL Configuration in CodeIgniter Using Laragon - tarcisiodev1 - 10-16-2023 (10-16-2023, 09:36 PM)kenjis Wrote: Yes. Thank you very much for your help and attention! RE: Issue with Base URL Configuration in CodeIgniter Using Laragon - FlavioSuar - 10-17-2023 Good to know!! |