Skip to content

Adds ability to configure a prefix for the internal url #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/better_errors/error_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def rails_params
end

def uri_prefix
env["SCRIPT_NAME"] || ""
BetterErrors::Middleware.internal_url_prefix + env["SCRIPT_NAME"] || ""
end

def request_path
Expand Down
11 changes: 11 additions & 0 deletions lib/better_errors/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ def self.allow_ip!(addr)
allow_ip! "127.0.0.0/8"
allow_ip! "::1/128" rescue nil # windows ruby doesn't have ipv6 support

# Set this if you are running your app under a path which it is not aware of.
@internal_url_prefix = ""

def self.internal_url_prefix
@internal_url_prefix
end

def self.internal_url_prefix=(value)
@internal_url_prefix = value
end

# A new instance of BetterErrors::Middleware
#
# @param app The Rack app/middleware to wrap with Better Errors
Expand Down