Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:M0ses:infra
barcodebuddy
0010-use_BASEURL_in_getApiUrl.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0010-use_BASEURL_in_getApiUrl.patch of Package barcodebuddy
commit 66bb22a8a818bcea0be7db55e518a39301bd8b5b Author: Frank Schreiner <schreiner@suse.de> Date: Wed Oct 18 11:45:14 2023 +0200 prefer BASEURL in getApiUrl This patch should fix the problem that "Add mobile app" is showing the "calculated" URL using '$_SERVER' variables but ignoring 'BASEURL' from the config.php. Without this patch, systems behind a reverse proxy are exposing their internal settings and do not generate a URL containing the "official" domain/url diff --git a/incl/processing.inc.php b/incl/processing.inc.php index 0b47493..c5c8bd7 100755 --- a/incl/processing.inc.php +++ b/incl/processing.inc.php @@ -729,6 +729,10 @@ function generateRandomString(int $length = 30): string { } function getApiUrl(string $removeAfter): string { + $baseurl = BBConfig::getInstance()["BASEURL"]; + if ($baseurl && preg_match('/^https?:\/\//',$baseurl)) { + return preg_replace("/\/+$/", '', $baseurl) . "/api/"; + } $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor