channel-worker 1.6.18 → 1.6.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/nst-manager.js +13 -25
- package/package.json +1 -1
package/lib/nst-manager.js
CHANGED
|
@@ -117,33 +117,21 @@ class NstManager {
|
|
|
117
117
|
async setProxy(profileId, proxyUrl) {
|
|
118
118
|
if (!proxyUrl) return;
|
|
119
119
|
console.log(`[nst] Setting proxy for ${profileId}: ${proxyUrl}`);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Try PATCH first, fallback to PUT
|
|
132
|
-
for (const method of ['PATCH', 'PUT']) {
|
|
133
|
-
try {
|
|
134
|
-
const res = await fetch(`${this.baseUrl}/profiles/${profileId}`, {
|
|
135
|
-
method,
|
|
136
|
-
headers: { 'Content-Type': 'application/json', 'x-api-key': this.apiKey },
|
|
137
|
-
body: JSON.stringify(proxyConfig),
|
|
138
|
-
});
|
|
139
|
-
const text = await res.text();
|
|
140
|
-
console.log(`[nst] setProxy ${method} ${res.status}: ${text.substring(0, 200)}`);
|
|
141
|
-
if (res.ok) { console.log(`[nst] Proxy saved to profile (${method})`); return; }
|
|
142
|
-
} catch (e) {
|
|
143
|
-
console.warn(`[nst] setProxy ${method} error: ${e.message}`);
|
|
120
|
+
try {
|
|
121
|
+
const res = await fetch(`${this.baseUrl}/profiles/${profileId}/proxy`, {
|
|
122
|
+
method: 'PUT',
|
|
123
|
+
headers: { 'Content-Type': 'application/json', 'x-api-key': this.apiKey },
|
|
124
|
+
body: JSON.stringify({ url: proxyUrl }),
|
|
125
|
+
});
|
|
126
|
+
const text = await res.text();
|
|
127
|
+
if (res.ok) {
|
|
128
|
+
console.log(`[nst] Proxy saved to profile`);
|
|
129
|
+
} else {
|
|
130
|
+
console.warn(`[nst] setProxy failed ${res.status}: ${text.substring(0, 200)}`);
|
|
144
131
|
}
|
|
132
|
+
} catch (e) {
|
|
133
|
+
console.warn(`[nst] setProxy error: ${e.message}`);
|
|
145
134
|
}
|
|
146
|
-
console.warn(`[nst] Failed to save proxy to profile — will still use at launch time`);
|
|
147
135
|
}
|
|
148
136
|
|
|
149
137
|
// Launch browser — skip if already running, set proxy if provided
|