I’m trying to add sidekiq to my webapp and want to mount the Sidekiq Web.
# frozen_string_literal: true
require "sidekiq/web"
require "sidekiq-scheduler/web"
module WebApp
class Routes < Hanami::Routes
mount Sidekiq::Web, at: "/sidekiq"
slice :api, at: "/api" do
use :body_parser, :json
post "/graphql/api", to: "graphql.api"
end
end
end
Sidekiq Web needs HTTP-sessions. How to enable HTTP-sessions just for Sidekiq Web?
I cannot put following in config/app.rb, because then I get a Hanami::Action::InvalidCSRFTokenError when I request the api.
To disable CSRF protection, you can implement the following hook method in one action:
private
def verify_csrf_token?(*)
false
end
Of course, if you want to share this behavior across the app, implement it as a private method of your action base class (e.g., MyApp::Action in app/action.rb).