Skip to content

supersurviveur/nextjs-mjpeg-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nextjs mjpeg proxy

A node.js module to proxy MJPEG requests. Supports multiple client consuming a single stream. Use web Response object.

Installation

From npm :

npm install nextjs-mjpeg-proxy

Example

Example Usage

You can use the proxy in the new Nextjs app router

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'
    })
}

API

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.

Credits

Original prototype version from:

About

A Node.JS MJPEG proxy implementation for NextJs route handler.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%