Skip to content

Instantly share code, notes, and snippets.

@camelloj
Last active September 16, 2025 12:14
Show Gist options
  • Select an option

  • Save camelloj/afec44d25fc84fcf8aecdb157076a9bf to your computer and use it in GitHub Desktop.

Select an option

Save camelloj/afec44d25fc84fcf8aecdb157076a9bf to your computer and use it in GitHub Desktop.
Sinatra ruby app Host authorization
# Set list of host that can interact with your app
require "sinatra/base"
class ExampleApp < Sinatra::Base
# disable it for all environments
set :host_authorization, { permitted_hosts: [] }
# or...
# disable it only for development
configure :development do
set :host_authorization, { permitted_hosts: [] }
end
# but enable it for production for some domains
configure :production do
set :host_authorization, { permitted_hosts: [".example.com"] }
end
get("/") { "OK" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment