diff --git a/Configuration.md b/Configuration.md index 8702206d49a1..7202743b4816 100644 --- a/Configuration.md +++ b/Configuration.md @@ -83,7 +83,7 @@ Notes: | Environment Variable | Description | Default Value | | --------- | ------------------ | --- | | PWP__DEFAULT_LOCALE | Sets the default language for the application. See the [documentation](https://github.com/pglombardo/PasswordPusher#internationalization). | `en` | -| PWP__RELATIVE_ROOT | Runs the application in a subfolder. e.g. `/pwp` --> `https://url/pwp` | `Not set` | +| PWP__RELATIVE_ROOT | Runs the application in a subfolder. e.g. With a value of `pwp` the front page will then be at `https://url/pwp` | `Not set` | ## Push Form Defaults diff --git a/config/defaults/settings.yml b/config/defaults/settings.yml index 876818af4255..0e26fbaa2361 100644 --- a/config/defaults/settings.yml +++ b/config/defaults/settings.yml @@ -505,5 +505,6 @@ log_to_stdout: false # To run in a subfolder, specify the path to use. For example, if `relative_root` # is set too 'pwpush_root', then the application is hosted at https:///pwpush_root/ # (and this is where you will find the front page of the application). +# # Environment variable override: PWP__RELATIVE_ROOT='pwpush' -# relative_root: '/pwpush' +# relative_root: 'pwpush' diff --git a/config/routes.rb b/config/routes.rb index fab087d96764..6cf249c31ea3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,7 @@ end apipie + localized do devise_for :users, skip: :registrations, controllers: { sessions: 'users/sessions', @@ -51,9 +52,11 @@ # This allows for running the application in a subfolder. See config/settings.yml (relative_root) if Settings.relative_root - scope(:path => Settings.relative_root) do + scope("#{Settings.relative_root}/:locale") do routes_config.call end + # Remap the root to the default locale + get Settings.relative_root, to: redirect("/#{Settings.relative_root}/#{I18n.default_locale}", status: 302) else routes_config.call end diff --git a/config/settings.yml b/config/settings.yml index 876818af4255..0e26fbaa2361 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -505,5 +505,6 @@ log_to_stdout: false # To run in a subfolder, specify the path to use. For example, if `relative_root` # is set too 'pwpush_root', then the application is hosted at https:///pwpush_root/ # (and this is where you will find the front page of the application). +# # Environment variable override: PWP__RELATIVE_ROOT='pwpush' -# relative_root: '/pwpush' +# relative_root: 'pwpush'