Last active
December 28, 2023 06:51
-
-
Save mallendeo/b4c708834f01382e363bb4d513efc467 to your computer and use it in GitHub Desktop.
NodeJS reverse proxy with websocket support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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