是否可以在浏览器中创建本地javascript代理?
我的html页面中有一个视频播放器:是否可以在浏览器中创建本地javascript代理?,javascript,browser,server,proxy,streaming,Javascript,Browser,Server,Proxy,Streaming,我的html页面中有一个视频播放器: <video width="720" height="405" controls poster="http://www.supportduweb.com/page/media/videoTag/BigBuckBunny.png"> <source src="localhost:3000/video?id=videoId" type="video/mp4"> Your browser does not support t
<video width="720" height="405" controls poster="http://www.supportduweb.com/page/media/videoTag/BigBuckBunny.png">
<source src="localhost:3000/video?id=videoId" type="video/mp4">
Your browser does not support the video tag or the file format of this video. <a href="http://www.supportduweb.com/">http://www.supportduweb.com/</a>-->
</video>
您的浏览器不支持此视频的视频标记或文件格式。-->
url指向由生成的本地代理。代理负责在数据解密后通过管道传输来自另一台服务器的响应
它实际上在我的电子应用程序中非常有效。问题是,现在,我需要这个在浏览器中工作。我找不到在浏览器中生成代理的方法
是否有另一种方法可以将流媒体指向一种代理,以便能够处理请求并返回作为http响应的定制响应
下面的模式可能更明确地解释了这个问题:有一个名为axios的包,它非常好而且成熟。使用它,您可以指定一个基本url,该url可以是与您的客户端运行所在的域不同的域。也可以创建自己的代理。我会举一些例子,但不包括它们的文档。解释得很好,也很容易使用。只需查找axios、下载模块或链接dns即可
// You can also define your proxy using the conventional `http_proxy` and
// `https_proxy` environment variables. If you are using environment variables
// for your proxy configuration, you can also define a `no_proxy` environment
// variable as a comma-separated list of domains that should not be proxied.
// Use `false` to disable proxies, ignoring environment variables.
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
// supplies credentials.
// This will set an `Proxy-Authorization` header, overwriting any existing
// `Proxy-Authorization` custom headers you have set using `headers`.
proxy: {
host: '127.0.0.1',
port: 9000,
auth: {
username: 'mikeymike',
password: 'rapunz3l'
}
},
有一个叫做axios的软件包,它非常好而且成熟。使用它,您可以指定一个基本url,该url可以是与您的客户端运行所在的域不同的域。也可以创建自己的代理。我会举一些例子,但不包括它们的文档。解释得很好,也很容易使用。只需查找axios、下载模块或链接dns即可
// You can also define your proxy using the conventional `http_proxy` and
// `https_proxy` environment variables. If you are using environment variables
// for your proxy configuration, you can also define a `no_proxy` environment
// variable as a comma-separated list of domains that should not be proxied.
// Use `false` to disable proxies, ignoring environment variables.
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
// supplies credentials.
// This will set an `Proxy-Authorization` header, overwriting any existing
// `Proxy-Authorization` custom headers you have set using `headers`.
proxy: {
host: '127.0.0.1',
port: 9000,
auth: {
username: 'mikeymike',
password: 'rapunz3l'
}
},
谢谢,我已经试用过这个软件包,但我一定会再试一次,然后马上回复您!问题是我无法运行节点服务器。目标是无服务器(我所说的服务器是一个p2p库)。因此,很遗憾,我无法使用此软件包……但我可以在index.html unpkg.com/axios/dist/axios.min.js上添加dns链接“>所以答案是否定的。下面有一个很好的解释。谢谢,我已经尝试过这个软件包,但我肯定会再试一次,然后马上返回给您!问题是我无法运行节点服务器。目标是无服务器(我所说的服务器是一个p2p库)。因此,很遗憾,我无法使用此软件包…但我可以在index.html unpkg.com/axios/dist/axios.min.js“>上添加dns链接,因此答案是否定的。下面有一个很好的解释