Skip to content

Commit

Permalink
fix: websocket endpoint error
Browse files Browse the repository at this point in the history
  • Loading branch information
yusong.hy committed Nov 16, 2023
1 parent 1765eee commit 1ad1280
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
3 changes: 3 additions & 0 deletions lib/service_websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const qs = require('qs');
const url = require('url');
const http = require('http');
const crypto = require('crypto');
const path = require('path');
const systemSign = require('hc-service-client/lib/signature/system_call');

const utils = require('./utils');
Expand Down Expand Up @@ -40,6 +41,8 @@ module.exports = function (u, proxyHeaders) {
let defaultQuery = u.defaultQuery instanceof Object ? u.defaultQuery : qs.parse(u.defaultQuery);
let customerQuery = qs.parse(url.parse(clientReq.url).query);
options.path = utils.mergeQuery(proxyUrl, defaultQuery, customerQuery);
options.url = path.join(u.endpoint, options.path);
options.path = url.parse(options.url).path;

const sign = systemSign({
accessKeyId: u.accessKeyId,
Expand Down
3 changes: 3 additions & 0 deletions lib/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const qs = require('qs');
const url = require('url');
const http = require('http');
const crypto = require('crypto');
const path = require('path');


const utils = require('./utils');
Expand Down Expand Up @@ -36,6 +37,8 @@ module.exports = function (u, proxyHeaders) {
let defaultQuery = u.defaultQuery instanceof Object ? u.defaultQuery : qs.parse(u.defaultQuery);
let customerQuery = qs.parse(url.parse(clientReq.url).query);
options.path = utils.mergeQuery(proxyUrl, defaultQuery, customerQuery);
options.url = path.join(u.endpoint, options.path);
options.path = url.parse(options.url).path;

const proxyReq = http.request(options);
proxyReq.on('error', (err) => {
Expand Down

0 comments on commit 1ad1280

Please sign in to comment.