Help Center/
Object Storage Service/
SDK Reference/
Node.js/
Initialization (SDK for Node.js)/
Configuring an SDK Proxy (SDK for Node.js)
Updated on 2024-11-13 GMT+08:00
Configuring an SDK Proxy (SDK for Node.js)
If you have any questions during development, post them on the Issues page of GitHub.
- In the root directory of the project, run the following command to download the proxy-agent dependency.
npm install --save proxy-agent
- Declare and configure proxies in the project.
const ProxyAgent = require("proxy-agent"); const proxyAgent = new ProxyAgent(`http://username:password@proxyhost:proxyPort`);
- Initialize an ObsClient instance and configure a proxy.
var obsClient = new ObsClient({ // Obtain an AK/SK pair using environment variables or import an AK/SK pair in other ways. Using hard coding may result in leakage. // Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/intl/en-us/usermanual-ca/ca_01_0003.html. access_key_id: process.env.ACCESS_KEY_ID, secret_access_key: process.env.SECRET_ACCESS_KEY, // If you use a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage. You can obtain an AK/SK pair using environment variables or import an AK/SK pair in other ways. security_token: process.env.SECURITY_TOKEN, // Enter the endpoint corresponding to the region where the bucket is located. CN-Hong Kong is used here as an example. Replace it with the one currently in use. server: "https://obs.ap-southeast-1.myhuaweicloud.com" https_agent:proxyAgent, http_agent: proxyAgent, });
Parent topic: Initialization (SDK for Node.js)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot