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
http-proxy-middleware should proxy my requests from my localhost to my remote Heroku API, successfully returning Heroku's response.
Actual behavior
The request just hangs. No error is thrown. Eventually the client gives up and reports 499 Client Disconnected.
Setup
http-proxy-middleware: ^0.17.1
server: express ^4.14.0
I'm using a few other things (compression, body-parser) but I don't think they're getting in my way.
proxy middleware configuration
constfs=require('fs'),express=require('express'),bodyParser=require('body-parser'),app=express(),compress=require('compression'),packageJson=JSON.parse(fs.readFileSync('package.json','utf8')),Routes=require('./Routes'),httpProxy=require('http-proxy-middleware');// NOTE: not my real subdomainconstAPI_SERVER='https://my-api.herokuapp.com';app.use(bodyParser.json({limit: '50mb'}));app.use(bodyParser.urlencoded({extended: false}));app.disable('x-powered-by');// Enable HTTP gzip compression.app.use(compress());// apply reverse proxy to heroku APIapp.use('/api',httpProxy({logLevel : 'debug',target : API_SERVER,changeOrigin : true,secure : false,xfwd : true,router: {'/api/auth/login': `${API_SERVER}/auth/login`},onProxyReq : function(proxyReq,req,res){// Browers may send Origin headers even with same-origin// requests. To prevent CORS issues, we have to change// the Origin to match the target URL.if(proxyReq.getHeader('origin')){proxyReq.setHeader('origin',API_SERVER);}}}));app.all('*',function(req,res,next){res.set({'www-version': `${packageJson.version}`,'X-Frame-Options': 'DENY','Cache-control': 'no-store','Pragma': 'no-cache','Strict-Transport-Security': 'max-age='+(365*24*60*60)// 365 days, in seconds});next();});// apply other, non-proxied routesapp.use(Routes);// Define the port.constport=process.env.PORT||4000;// Start the HTTP server.app.listen(port,()=>{console.log(`App listening on port ${port}!`);});
The text was updated successfully, but these errors were encountered:
Expected behavior
http-proxy-middleware
should proxy my requests from my localhost to my remote Heroku API, successfully returning Heroku's response.Actual behavior
The request just hangs. No error is thrown. Eventually the client gives up and reports
499 Client Disconnected
.Setup
compression
,body-parser
) but I don't think they're getting in my way.proxy middleware configuration
The text was updated successfully, but these errors were encountered: