DEV Community

Nabeel Valley
Nabeel Valley

Posted on • Originally published at nabeelvalley.co.za on

stdout: Localhost HTTP Proxy with Node.js

Contents

A localhost HTTP proxy is useful for debugging and can be easily defined using Node.js by installing http-proxy

yarn add http-proxy

Enter fullscreen mode Exit fullscreen mode

And then adding the following to an index.js file:

index.js

const httpProxy = require('http-proxy')

const target = 'http://my-target-website.com:1234'

httpProxy.createProxyServer({ target }).listen(8080)

Enter fullscreen mode Exit fullscreen mode

Which will create a server that listens on 8080 and will proxy requests to the target

Top comments (0)

This post blew up on DEV in 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay