You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if it is a matter of configuration ( or what is the correct way of doing that )
I have a PHP server serving api, and in order to get the response, I need to get a token. If there is no token or an invalid token, it will denied your access. The token is session based.
The sequence is like that
get the token ( /api/token )
append the token to the proxy request
I'm able to do that when I do that sequence from the browser, but when I used the proxy, I can't get that working.
The following is a middleware for a particular route
// testGetTokenMiddleware.js
export default (req, res, next) => {
// There are some more code for performance, but following is the "stripped" relevant code.
request(`${config.get('myUrl')}/get_token`, function(err, response, body) {
if(err) {
response.send(404);
}
const tokenResponse = JSON.parse(body);
// I then append the token to my url, but when I debug further, this token is not the same as the token in the "PHP session"
req.session.phpToken = tokenRsponse.token;
next();
});
}
And later on I use that middleware in one of my route
import testGetTokenMiddleware from 'testGetTokenMiddleware';
// ... ignore some other code ... blah
router.get('/api/test', testGetTokenMiddleware, myProxy);
When I debug the issue, I found out that the token that I got from the middleware is different from the token in the php session. ( Maybe it is passing the wrong Cookie, or the request and proxy is on different sessions ?? ) Wondering what is the best way to solve that issue.
Thanks
The text was updated successfully, but these errors were encountered:
iroy2000
changed the title
[ Question ] What is the correct way to use proxy to get session token from PHP
[ Question ] What is the correct way to use proxy if there is an dependency request
Aug 27, 2016
Not sure if it is a matter of configuration ( or what is the correct way of doing that )
I have a PHP server serving api, and in order to get the response, I need to get a token. If there is no token or an invalid token, it will denied your access. The token is session based.
The sequence is like that
I'm able to do that when I do that sequence from the browser, but when I used the proxy, I can't get that working.
The following is a middleware for a particular route
And later on I use that middleware in one of my route
When I debug the issue, I found out that the token that I got from the middleware is different from the token in the php session. ( Maybe it is passing the wrong Cookie, or the
request
andproxy
is on different sessions ?? ) Wondering what is the best way to solve that issue.Thanks
The text was updated successfully, but these errors were encountered: