3

I have a nodejs application running using express on my localhost. I use bootstrap as well. The problem is that at my workplace I have to use proxy settings. Once I type localhost:3000 it gets redirected to an IP address that does not run. If I remove the proxy settings from Google Chrome localhost:3000 works some of the times but without the bootstrap styling.

I am also using routes to direct different urls to the corresponding ejs pages:

router.get('/', function(req, res, next) {  
  res.render('index', {});
});

The index.ejs file has a URL pointing to the bootstrap css online remote file.

Is there a way to have it running using the proxy as well.

Thank you in advance :)

4
  • Try to just use 127.0.0.1:3000 instead localhost:3000 at work Commented Aug 24, 2015 at 13:06
  • I tried it but it didn't work :( Thank you :) Commented Aug 24, 2015 at 13:12
  • So the problem is the remote file, why you need it to be remote? Can't you put it locally to your app? That's the way to go. Commented Aug 24, 2015 at 13:13
  • The problem is with any file even id it does not contain a reference to bootstrap. Thank you :) Commented Aug 24, 2015 at 14:48

1 Answer 1

1

Use module http-proxy

npm install http-proxy

It is then possible to proxy requests by calling these functions

const httpProxy = require('http-proxy');

//
// Create your proxy server and set the target in the options.
//
httpProxy.createProxyServer({ target:'http://192.168.126.128:8080' }).listen(9000);

For more information visit https://github.com/nodejitsu/node-http-proxy

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.