diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 289d6784..cabdb0e4 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -33,6 +33,16 @@ def results when *timdex_tabs load_timdex_results end + + return unless request.format.json? + + if params[:sekret].present? && params[:sekret] == ENV['SECRET_REQUEST_API_KEY'] + render json: { results: @results, + pagination: @pagination, + errors: @errors } + else + render json: { error: 'Unauthorized request' }, status: :unauthorized + end end private