I think I can phrase my question, generally, as I think this issue applies to many of us.
So, what if I am using JWT Authentication for WP REST API since I need to access user-authenticated data (like the user public name) from the frontend using the API. I have already done that, and it works. I also store the JWT as a cookie so, when someone has already logged in, they don’t have to log in again.
But what if the user has logged in, say, yesterday and they now want to go to my application. They already have a JWT token stored in a cookie, so, when they load the app, I need them to have their user-authenticated data without having to perform a fetch from the client (because that takes time).
Is this possible? Keep in mind that the request goes to the server (and the NodeJS app) with the cookie in an HTTP Header called “Cookie” (the browser sends it automatically) thus, I should be able to access the JWT from the NodeJS app. However, I only have access to the ReactJS code which can’t access http request parameters, right? or…
Is there a way to capture the cookie in the NodeJS server code in such a way that it is accessible from the ReactJS code (and thus, being able to perform a user-authenticated fetch?)