Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 8a926ac

Browse files
bug fix redirect url with docker installation
1 parent 0360176 commit 8a926ac

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
restart: "unless-stopped"
66
environment:
77
TYPE: "docker"
8+
BASE_URL: "https://mydomain.com"
89
DATABASE_HOST: "php-dynamic-qrcode-db"
910
DATABASE_PORT: "3306"
1011
DATABASE_NAME: "qrcode"
@@ -17,7 +18,6 @@ services:
1718
depends_on:
1819
- php-dynamic-qrcode-db
1920
volumes:
20-
- php_dynamic_qrcode_config_data:/var/www/html/config
2121
- php_dynamic_qrcode_saved_qrcode_data:/var/www/html/saved_qrcode
2222
networks:
2323
- php-dynamic-qrcode-network

src/config/environment.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
define('DATABASE_PASSWORD', Getenv('DATABASE_PASSWORD'));
1414
define('DATABASE_PREFIX', Getenv('DATABASE_PREFIX')); // This must have a trailing underscore. Example: qr_
1515
define('DATABASE_CHARSET', Getenv('DATABASE_CHARSET'));
16+
define('TYPE', Getenv('TYPE'));
17+
define('BASE_URL', Getenv('BASE_URL'));
1618
} else {
1719
define('DATABASE_HOST', "localhost");
1820
define('DATABASE_PORT', "3306");

src/helpers/helpers.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,16 @@ function paginationLinks($current_page, $total_pages, $base_url) {
117117
return $html;
118118
}
119119

120-
function base_url(){
121-
return sprintf(
122-
"%s://%s:%s",
123-
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
124-
$_SERVER['SERVER_NAME'],
125-
$_SERVER['SERVER_PORT']
126-
);
120+
function base_url() {
121+
require_once(__DIR__ . '/../config/environment.php');
122+
if (defined('BASE_URL') && BASE_URL !== null) {
123+
return BASE_URL;
124+
} else {
125+
return sprintf(
126+
"%s://%s:%s",
127+
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http',
128+
$_SERVER['SERVER_NAME'],
129+
$_SERVER['SERVER_PORT']
130+
);
131+
}
127132
}

0 commit comments

Comments
 (0)