MJPEG Proxy for the nextjs app router
npm install nextjs-mjpeg-proxyA node.js module to proxy MJPEG requests. Supports multiple client consuming a single stream. Use web Response object.
From npm :
``bash`
npm install nextjs-mjpeg-proxy
You can use the proxy in the new Nextjs app router
`ts
import MjpegProxy from 'nextjs-mjpeg-proxy'
const webcamURL = http://${process.env.NEXT_PUBLIC_WEBCAM_IP}/mjpg/video.mjpg
const proxy = new MjpegProxy(webcamURL)
export async function GET() {
return proxy.proxyRequest({
'Content-Disposition': 'inline; filename="My webcam"',
'X-Robots-Tag': 'noindex'
})
}
`
` js`
const proxy = new MjpegProxy(webcamURL)
MjpegProxy.proxyRequest(customHeaders: HeadersInit = {}) is a method returning a web Response` object, initialized with a mjpeg stream and custom headers passed in parameter.
Original prototype version from:
* Phil Rene (philrene)
* Chris Chua (chrisirhc)
* Georges-Etienne Legendre (legege)