feat(config): introduce appBaseUrl for overriding client and server base URLs (#405)

- Added appBaseUrl configuration to allow users to set a base URL that overrides both client and server base URLs.
- Updated documentation to reflect the new configuration variable and its usage.
- Refactored relevant code to utilize appBaseUrl where applicable, ensuring consistent behavior across the application.
- Enhanced tests to verify the correct application of appBaseUrl in various scenarios.
This commit is contained in:
Corentin Thomasset
2025-07-13 21:46:07 +02:00
committed by GitHub
parent 26015666de
commit 3401cfbfdc
14 changed files with 112 additions and 40 deletions
@@ -11,6 +11,19 @@ import { Code } from '@astrojs/starlight/components';
Configuring your self hosted Papra allows you to customize the application to better suit your environment and requirements. This guide covers the key environment variables you can set to control various aspects of the application, including port settings, security options, and storage configurations.
## Complete .env
Here is the full configuration file that you can use to configure Papra. The variables values are the default values.
<Code code={fullDotEnv} language="env" title=".env" />
## Configuration variables
Here is the complete list of configuration variables that you can use to configure Papra. You can set these variables in the `.env` file or pass them as environment variables when running the Docker container.
<Fragment set:html={sectionsHtml} />
## Configuration files
You can configure Papra using standard environment variables or use some configuration files.
@@ -71,17 +84,4 @@ Example of configuration files:
</Tabs>
You'll find the complete list of configuration variables with their environment variables equivalents and path for files in the next section.
## Complete .env
Here is the full configuration file that you can use to configure Papra. The variables values are the default values.
<Code code={fullDotEnv} language="env" title=".env" />
## Configuration variables
Here is the complete list of configuration variables that you can use to configure Papra. You can set these variables in the `.env` file or pass them as environment variables when running the Docker container.
<Fragment set:html={sectionsHtml} />
You'll find the complete list of configuration variables with their environment variables equivalents and path for files in the previous section.
@@ -16,8 +16,7 @@ services:
- 1221:1221
environment:
- AUTH_SECRET=change-me
- CLIENT_BASE_URL=http://localhost:1221
- SERVER_BASE_URL=http://localhost:1221
- APP_BASE_URL=http://localhost:1221
volumes:
- ./app-data:/app/app-data
user: 1000:1000
@@ -281,19 +280,14 @@ function getDockerComposeYml() {
const intakeEmailEnabled = intakeEmailEnabledSelect.value === 'true';
const intakeDriver = intakeDriverSelect.value;
const webhookSecret = webhookSecretInput.value;
const appBaseUrl = appBaseUrlInput.value.trim();
const appBaseUrl = appBaseUrlInput.value.trim() || `http://localhost:${port}`;
const version = isRootless ? 'latest' : 'latest-root';
const fullImage = `${image}:${version}`;
// Determine base URLs
const clientBaseUrl = appBaseUrl || `http://localhost:${port}`;
const serverBaseUrl = appBaseUrl || `http://localhost:${port}`;
const environment = [
`AUTH_SECRET=${authSecret}`,
`CLIENT_BASE_URL=${clientBaseUrl}`,
`SERVER_BASE_URL=${serverBaseUrl}`,
`APP_BASE_URL=${appBaseUrl}`,
isIngestionEnabled && 'INGESTION_FOLDER_IS_ENABLED=true',
intakeEmailEnabled && 'INTAKE_EMAILS_IS_ENABLED=true',
intakeEmailEnabled && `INTAKE_EMAILS_DRIVER=${intakeDriver}`,