Is it possible to access response headers of an HTML request sent to the browser via ruby (in controllers)?
What I am doing?
I am trying to authenticate a login request using devise
and devise-jwt
in a rails app. After successful authentication I am assigned an Authorization token in response headers and redirected to a after_sign_in_path
. Now on browser I can see the token being received, however I also need the same token issued in the controller action before it goes to the browser.
Upon parsing/logging response headers(response.headers
) in the controller action(responsible for rendering the same view), i don't see Authorization key at all.
Alternative: Tried using javascript but as it turns out you can only parse response headers of a request initiated by javascript. This link states the same
Is there a way i can achieve this and not resort to using ajax request method?