Split BASE_URL into URL_{SCHEME,HOST,PORT}

remove-old-upload-endpoint
Marcin Kulik 7 years ago
parent 8d80aeb9b1
commit b2234929ca

@ -4,7 +4,9 @@
## Values after "=" sign are taken as-is, so don't use double quotes for strings.
## Base URL of your asciinema web app instance
BASE_URL=http://localhost:3000
URL_SCHEME=http
URL_HOST=localhost
URL_PORT=3000
## Base secret key for signing cookies etc.
## Run `docker-compose run --rm web bundle exec rake secret`

@ -67,7 +67,11 @@ module Asciinema
)
end
config.action_mailer.default_url_options = { protocol: CFG.scheme, host: CFG.hostname_with_port }
config.action_mailer.default_url_options = {
protocol: CFG.url_scheme,
host: CFG.url_host,
port: CFG.url_port
}
if CFG.smtp_settings
config.action_mailer.smtp_settings = CFG.smtp_settings

@ -4,7 +4,9 @@ module Asciinema
class Configuration
include Virtus.model
attribute :base_url, String, default: 'http://localhost:3000'
attribute :url_scheme, String, default: "http"
attribute :url_host, String, default: "localhost"
attribute :url_port, Integer, default: 3000
attribute :bugsnag_api_key, String
attribute :aws_access_key_id, String
attribute :aws_secret_access_key, String
@ -28,31 +30,12 @@ module Asciinema
end
end
def scheme
URI.parse(base_url).scheme
end
def hostname
URI.parse(base_url).hostname
end
def hostname_with_port
uri = URI.parse(base_url)
hwp = uri.hostname
if uri.port != uri.default_port
hwp = "#{hwp}:#{uri.port}"
end
hwp
end
def ssl?
scheme == 'https'
url_scheme == 'https'
end
def smtp_from_address
super || "asciinema <hello@#{hostname}>"
super || "asciinema <hello@#{url_host}>"
end
end
end

@ -13,7 +13,9 @@ use Mix.Config
# which you typically run after static files are built.
config :asciinema, Asciinema.Endpoint,
http: [port: {:system, "PORT"}],
url: [scheme: "https", host: "asciinema.org", port: 443],
url: [scheme: System.get_env("URL_SCHEME") || "https",
host: System.get_env("URL_HOST") || "asciinema.org",
port: String.to_integer(System.get_env("URL_PORT") || "443")],
cache_static_manifest: "priv/static/manifest.json"
# Do not print debug messages in production

Loading…
Cancel
Save