[Vuejs]-Successful login (status code 200) leads to status code 401 GET request

0👍

I use the same source project and faced the same problem, but it only happens in my production environment. It is ok in the development environment. I figured it out the problem is in the signin_controller.rb

 if user.authenticate(params[:password])
      payload = { user_id: user.id }
      session = JWTSessions::Session.new(payload: payload, refresh_by_access_allowed: true)
      tokens = session.login
      response.set_cookie(JWTSessions.access_cookie,
                          value: tokens[:access],
                          httponly: true,
                          secure: Rails.env.production?)
                          )
      render json: { csrf: tokens[:csrf] }

Since my site is not using HTTPS, I change secure: Rails.env.production? to secure: false, then it works fine.

Leave a comment