-
I use 2 different addresses to access the internet. I want it to use the address I specified to make a request to mega. It's hard to constantly change it from network settings. How can I specify the address to which requests should be made? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I'm assuming you are changing network settings outside the library. In order to change network settings related to the library follow the documentation: https://mega.js.org/docs/tutorial/network-settings In order to to set the local interface you need to use an agent as described in this node-fetch issue. To set up this agent in the library you, following the above documentation, just need to pass the agent to the import { Agent as HttpAgent } from 'http'
import { Agent as HttpsAgent } from 'https'
import { API, Storage } from 'megajs'
const httpAgent = new HttpAgent({ keepAlive: true, localAddress: '10.1.1.2' })
const httpsAgent = new HttpsAgent({ keepAlive: true, localAddress: '10.1.1.2' })
const globalApi = API.getGlobalApi()
globalApi.httpAgent = httpAgent
globalApi.httpsAgent = httpsAgent
const storage = new Storage({
email: '...',
password: '...',
httpAgent,
httpsAgent
}) |
Beta Was this translation helpful? Give feedback.
I'm assuming you are changing network settings outside the library. In order to change network settings related to the library follow the documentation: https://mega.js.org/docs/tutorial/network-settings
In order to to set the local interface you need to use an agent as described in this node-fetch issue. To set up this agent in the library you, following the above documentation, just need to pass the agent to the
Storage
constructor or replace it in the global agent: