Home>

I need to add a Sidekiq web interface project to Rails, but I says that I have a problem with CSRF.

That's what writes:

Sidekiq :: Web Needs a Valid Rack Session for CSRF Protection. If This Is A Rails App,
Make Sure You Mount Sidekiq :: Web * Inside * Your Application Routes:
Rails.application.Routes.Draw Do.
Mount Sidekiq :: Web= >
 "/Sidekiq"
....
End.
If This Is a Bare Rack App, USE A Session Middleware Before Sidekiq :: Web:
# FIRST, USE IRB TO CREATE A SHARED SECRET KEY FOR SESSIONS AND COMMIT IT
Require 'SecureRandom'; File.open ("Session.key", "w") {| f | F.Write (SecureRandom.hex (32))}
# NOW Use The Secret with a Session Cookie MiddleWare
Use Rack :: Session :: Cookie, Secret: File.read ("Session.key"), SAME_SITE: TRUE, MAX_AGE: 86400
RUN SIDEKIQ :: WEB

and releases below:

Def Session (ENV)
    ENV ["Rack.session"] || fail (<
≪
~ EOM)
      Sidekiq :: Web Needs A Valid Rack Session for CSRF Protection. If This Is A Rails App,
      Make Sure You Mount Sidekiq :: Web * Inside * Your Application Routes:

Here is my routes.rb:

Require 'Sidekiq'
Require 'Sidekiq /Web'
Rails.application.Routes.Draw Do.
  Mount Sidekiq :: Web= >
 "/Sidekiq"
  Namespace 'API' Do
    Namespace 'v1' do
      Resources: Diarias.
      Resources: Notes.
    End.
  End.
End.

strange that he tell me to register Mount Sidekiq :: Web= > "/Sidekiq" , despite the fact that it is already written

Try to stop the rail server, run the Spring Stop and start the server again

Василиса2021-03-22 12:54:42