Created
May 17, 2023 18:16
-
-
Save blakejakopovic/2e8fa806e1b85c17411b66b55f3df4e8 to your computer and use it in GitHub Desktop.
Revisions
-
blakejakopovic created this gist
May 17, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ require 'sinatra' get '/public/AUTHIMAGE.jpg' do auth_header = request.env['HTTP_AUTHORIZATION'] puts auth_header # Check if the header value starts with "Nostr " unless auth_header && auth_header.start_with?("Nostr ") headers['WWW-AUTHENTICATE'] = 'NOSTR-NIP-98' headers['Access-Control-Expose-Headers'] = 'WWW-Authenticate' headers['Access-Control-Allow-Origin'] = '*' halt 401, 'Unauthorized' end begin # Read the image file file_path = 'public/AUTHIMAGE.jpg' if File.exist?(file_path) send_file file_path, type: 'image/jpeg' else halt 404, 'Not Found' end rescue halt 500, 'Internal Server Error' end end # Start the Sinatra server set :port, 9550