Closed RwGrid closed 7 months ago
import { HttpProxyAgent } from "hpagent";
import { translate } from "bing-translate-api";
var myproxy = new HttpProxyAgent({
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 256,
maxFreeSockets: 256,
proxy: ...proxyUrl...
});
const result = await translate(text, source, destination, false, false, agent, { http: myproxy });
Hi,
@plainheart, is there a way to use MET translate with a proxy ?
I tried to use :
import { HttpsProxyAgent } from "hpagent";
const proxy = new HttpsProxyAgent({
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 256,
maxFreeSockets: 256,
proxy: config.proxy,
});
MET.translate(
req?.body?.text,
req?.body?.langIn || "auto-detect",
req?.body?.langOut,
{
https: proxy,
}
)
.then((data: any) => {
console.log(data);
res.status(200).send(data);
})
.catch((error: any) => {
console.error(error);
res.status(400).send(error);
});
but without success (it works with bing)
thank you !
@stephanebouget Hi, might be like this
import { HttpsProxyAgent } from 'hpagent'
const httpsAgent = new HttpsProxyAgent({
// ...
})
MET.translate('Hi', null, 'zh-Hans', {
gotOptions: {
agent: {
https: httpsAgent
}
}
})
with got compatible and which got version to use and how to define proxy agent