github facebook twitter

CORS Recipe

require "kemal"

static_headers do |response, filepath, filestat|
  if filepath =~ /\.html$/
    response.headers.add("Access-Control-Allow-Origin", "example.com")
  end
  response.headers.add("Content-Size", filestat.size.to_s)
end

Kemal.run

Source Code