Skip to content

Instantly share code, notes, and snippets.

@benvds
Last active December 21, 2015 04:19
Show Gist options
  • Save benvds/6248662 to your computer and use it in GitHub Desktop.
Save benvds/6248662 to your computer and use it in GitHub Desktop.
use of basic auth disables before block
require 'sinatra/base'
class TestRestApi < Sinatra::Base
before do
headers['Access-Control-Allow-Origin'] = '*'
content_type :json
end
# no more header & content_type when to following is enabled
use Rack::Auth::Basic, "Restricted Area" do |username, password|
username == 'admin' and password == 'secret'
end
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment