Websites/lib/middleware/dev_host.rb
Donovan Daniels b1c702e3cd
Add image management ui
poorly tested but it worked well enough, I'm sure I'll be patching bugs over the next few weeks
Also remove turbo because it sucks
Also changed the way we handle hosts in dev
2024-05-06 03:25:17 -05:00

24 lines
555 B
Ruby

# frozen_string_literal: true
module Middleware
class DevHost
DEFAULT_HOST = "v2.yiff.rest"
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
domain = request.params["domain"].presence || DEFAULT_HOST
if Rails.env.development? && domain
env["websites.dev_host"] = domain
env["websites.dev_domain"] = domain.split(".").last(2).join(".")
env["websites.dev_subdomains"] = domain.split(".")[0..-3].join(".")
end
@app.call(env)
end
end
end