From 8be14768dfb69a12a22743dcc7551be17ea58aa4 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 6 Mar 2020 20:41:00 +0100 Subject: [PATCH] Added new config.php setting for subdirectory base path (closes #568) --- app.php | 6 ++++++ changelog/56_UNRELEASED_2020-xx-xx.md | 3 +++ config-dist.php | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/app.php b/app.php index cf6d0851..af65ad1b 100644 --- a/app.php +++ b/app.php @@ -68,6 +68,12 @@ $container->set('ApiKeyHeaderName', function(Container $container) // Load routes from separate file require_once __DIR__ . '/routes.php'; +// Set base path if defined +if (!empty(GROCY_BASE_PATH)) +{ + $app->setBasePath(GROCY_BASE_PATH); +} + // Add default middleware $app->addRoutingMiddleware(); $app->addErrorMiddleware(true, false, false); diff --git a/changelog/56_UNRELEASED_2020-xx-xx.md b/changelog/56_UNRELEASED_2020-xx-xx.md index 0c1d293d..79751772 100644 --- a/changelog/56_UNRELEASED_2020-xx-xx.md +++ b/changelog/56_UNRELEASED_2020-xx-xx.md @@ -1,3 +1,6 @@ +## !! Important notice +If you run grocy in a subdirectory, you need to set a new `config.php` setting (`BASE_PATH`, see `config-dist.php`) + ### Stock fixes - Fixed purchase/consume/inventory problems when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was set to `false` diff --git a/config-dist.php b/config-dist.php index 76e50a5c..df69c012 100644 --- a/config-dist.php +++ b/config-dist.php @@ -37,6 +37,13 @@ Setting('CALENDAR_SHOW_WEEK_OF_YEAR', true); # ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.) Setting('CURRENCY', 'USD'); +# When running grocy in a subdirectory, this should be set to the relative path, otherwise empty +# Example: +# Webserver root directory = /var/www +# grocy directory = /var/www/grocy +# => BASE_PATH = /grocy +Setting('BASE_PATH', ''); + # The base url of your installation, # should be just "/" when running directly under the root of a (sub)domain # or for example "https://example.com/grocy" when using a subdirectory