node.js - POST request 404 (Not Found) - express-http-proxy -
i'm trying send post request api gives me following error:
i'm using express-http-proxy
package node send request. here code:
app.use('/api', proxy(targeturl, { forwardpath: (req, res) => { return require('url').parse(req.url).path; } }));
in reactjs application, i'm using superagent
pass request , here request creation code:
methods.foreach((method) => this[method] = (path, data = {}, params = {}) => new promise((resolve, reject) => { const request = superagent[method](formaturl(path)); request.set('token', 'cb460084804cd40'); if (params) { request.query(params); } if (__server__ && req.get('cookie')) { request.set('cookie', req.get('cookie')); } if (data) { request.send(data); } console.log('sending: ', request); // request.end((err, { text } = {}) => {console.log('ended: ', text, err);}); // reject(); request.end((err, { text } = {}) => err ? reject(text || err) : resolve(text)); }));
formaturl function
function formaturl(path) { const adjustedpath = path[0] !== '/' ? '/' + path : path; if (__server__) { return 'https://' + config.apihost + adjustedpath; } return '/api' + adjustedpath; }
in addition this, when send request, gives me following error:
also, when try send post request on live apiserver gives 404 not found error if try send post request on localhost apiserver gives 504 gateway_timeout error.
i not confident behaviour. therefore, need find problem. time in advance.
Comments
Post a Comment