I'm using Rails 7 API only and gem devise-jwt
to authentication. Firstly, this is tutorial to setup: https://dakotaleemartinez.com/tutorials/devise-jwt-api-only-mode-for-authentication/
It has a trouble, when i call API register new account, it shows a error: Your application has sessions disabled. To write to the session you must first configure a session store
Your application has sessions disabled. To write to the session you must first configure a session store
I try to fix this issue (Add session store configuration into the application config)
config.session_store :cookie_store, key: '_rails7_api_session'
config.middleware.use ActionDispatch::Cookies
config.middleware.use config.session_store, config.session_options
=> It worked, but i faced with the second trouble. I defined a "/me" route to get current user. In theory, I need to pass the Authorization
parameter on the header to be able to get the current user data (I'm using Postman). But somehow (Probably because of session) I get the user data without the Authorization
parameter on the header.
I want to fix this issue. Somebody can help me, please?
In the related /me
controller, have you put before_action:authenticate_user!
in the controller?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.