Skip to content

Commit

Permalink
Fix push URLs with a Relative Root (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
pglombardo authored Dec 21, 2022
1 parent 864046c commit 431cee8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion config/defaults/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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://<host>/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'
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
end

apipie

localized do
devise_for :users, skip: :registrations, controllers: {
sessions: 'users/sessions',
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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://<host>/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'

0 comments on commit 431cee8

Please sign in to comment.