Skip to content

Instantly share code, notes, and snippets.

@mallendeo
Last active December 28, 2023 06:51
Show Gist options
  • Save mallendeo/b4c708834f01382e363bb4d513efc467 to your computer and use it in GitHub Desktop.
Save mallendeo/b4c708834f01382e363bb4d513efc467 to your computer and use it in GitHub Desktop.
NodeJS reverse proxy with websocket support
import express from 'express'
import { createProxyMiddleware } from 'http-proxy-middleware'
const PORT = process.env.PORT || 8000
const app = express();
app.use(
'/',
createProxyMiddleware({
target: 'https://example.com',
changeOrigin: true,
ws: true
}),
)
app.listen(PORT);
console.log('Listening on port', PORT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment