diff --git a/backend/services/mikrotikApplyService.js b/backend/services/mikrotikApplyService.js index 29cb4aa..da2b281 100644 --- a/backend/services/mikrotikApplyService.js +++ b/backend/services/mikrotikApplyService.js @@ -15,7 +15,10 @@ const https = require('https'); */ function createRosClient(opts) { const { host, port = 80, user, password, secure = false } = opts; - const useHttp = port === 80; + // Порт может прийти строкой из JSON — приводим к числу + const portNumber = Number(port) || 80; + // REST API по умолчанию висит на HTTP:80, HTTPS обычно на 443/8443 + const useHttp = portNumber === 80; const protocol = useHttp ? http : https; const makeRequest = (method, urlPath, body = null) => { @@ -32,7 +35,7 @@ function createRosClient(opts) { if (bodyStr) headers['Content-Length'] = Buffer.byteLength(bodyStr, 'utf8'); const options = { hostname: host, - port, + port: portNumber, path: pathStr, method, headers, diff --git a/frontend/src/components/server/ServerModal.jsx b/frontend/src/components/server/ServerModal.jsx index 6a384a8..f98465a 100644 --- a/frontend/src/components/server/ServerModal.jsx +++ b/frontend/src/components/server/ServerModal.jsx @@ -588,9 +588,9 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter handleFieldChange('mikrotikPort', e.target.value)} - placeholder="8728" + placeholder="80" />