增加cors支持,更新依赖
Browse files- package-lock.json +67 -56
- package.json +3 -2
- src/server/index.js +2 -0
package-lock.json
CHANGED
|
@@ -10,9 +10,10 @@
|
|
| 10 |
"license": "MIT",
|
| 11 |
"dependencies": {
|
| 12 |
"axios": "^1.13.2",
|
|
|
|
| 13 |
"dotenv": "^17.2.3",
|
| 14 |
-
"express": "^5.1
|
| 15 |
-
"jsonwebtoken": "^9.0.
|
| 16 |
},
|
| 17 |
"engines": {
|
| 18 |
"node": ">=18.0.0"
|
|
@@ -49,23 +50,27 @@
|
|
| 49 |
}
|
| 50 |
},
|
| 51 |
"node_modules/body-parser": {
|
| 52 |
-
"version": "2.2.
|
| 53 |
-
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.
|
| 54 |
-
"integrity": "sha512-
|
| 55 |
"license": "MIT",
|
| 56 |
"dependencies": {
|
| 57 |
"bytes": "^3.1.2",
|
| 58 |
"content-type": "^1.0.5",
|
| 59 |
-
"debug": "^4.4.
|
| 60 |
"http-errors": "^2.0.0",
|
| 61 |
-
"iconv-lite": "^0.
|
| 62 |
"on-finished": "^2.4.1",
|
| 63 |
"qs": "^6.14.0",
|
| 64 |
-
"raw-body": "^3.0.
|
| 65 |
-
"type-is": "^2.0.
|
| 66 |
},
|
| 67 |
"engines": {
|
| 68 |
"node": ">=18"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
}
|
| 70 |
},
|
| 71 |
"node_modules/buffer-equal-constant-time": {
|
|
@@ -164,6 +169,19 @@
|
|
| 164 |
"node": ">=6.6.0"
|
| 165 |
}
|
| 166 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
"node_modules/debug": {
|
| 168 |
"version": "4.4.3",
|
| 169 |
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
|
@@ -310,18 +328,19 @@
|
|
| 310 |
}
|
| 311 |
},
|
| 312 |
"node_modules/express": {
|
| 313 |
-
"version": "5.1
|
| 314 |
-
"resolved": "https://registry.npmjs.org/express/-/express-5.1.
|
| 315 |
-
"integrity": "sha512-
|
| 316 |
"license": "MIT",
|
| 317 |
"dependencies": {
|
| 318 |
"accepts": "^2.0.0",
|
| 319 |
-
"body-parser": "^2.2.
|
| 320 |
"content-disposition": "^1.0.0",
|
| 321 |
"content-type": "^1.0.5",
|
| 322 |
"cookie": "^0.7.1",
|
| 323 |
"cookie-signature": "^1.2.1",
|
| 324 |
"debug": "^4.4.0",
|
|
|
|
| 325 |
"encodeurl": "^2.0.0",
|
| 326 |
"escape-html": "^1.0.3",
|
| 327 |
"etag": "^1.8.1",
|
|
@@ -541,40 +560,39 @@
|
|
| 541 |
}
|
| 542 |
},
|
| 543 |
"node_modules/http-errors": {
|
| 544 |
-
"version": "2.0.
|
| 545 |
-
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.
|
| 546 |
-
"integrity": "sha512-
|
| 547 |
"license": "MIT",
|
| 548 |
"dependencies": {
|
| 549 |
-
"depd": "2.0.0",
|
| 550 |
-
"inherits": "2.0.4",
|
| 551 |
-
"setprototypeof": "1.2.0",
|
| 552 |
-
"statuses": "2.0.
|
| 553 |
-
"toidentifier": "1.0.1"
|
| 554 |
},
|
| 555 |
"engines": {
|
| 556 |
"node": ">= 0.8"
|
| 557 |
-
}
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
| 562 |
-
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
|
| 563 |
-
"license": "MIT",
|
| 564 |
-
"engines": {
|
| 565 |
-
"node": ">= 0.8"
|
| 566 |
}
|
| 567 |
},
|
| 568 |
"node_modules/iconv-lite": {
|
| 569 |
-
"version": "0.
|
| 570 |
-
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.
|
| 571 |
-
"integrity": "sha512-
|
| 572 |
"license": "MIT",
|
| 573 |
"dependencies": {
|
| 574 |
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
| 575 |
},
|
| 576 |
"engines": {
|
| 577 |
"node": ">=0.10.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 578 |
}
|
| 579 |
},
|
| 580 |
"node_modules/inherits": {
|
|
@@ -749,6 +767,15 @@
|
|
| 749 |
"node": ">= 0.6"
|
| 750 |
}
|
| 751 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
"node_modules/object-inspect": {
|
| 753 |
"version": "1.13.4",
|
| 754 |
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
|
@@ -845,36 +872,20 @@
|
|
| 845 |
}
|
| 846 |
},
|
| 847 |
"node_modules/raw-body": {
|
| 848 |
-
"version": "3.0.
|
| 849 |
-
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.
|
| 850 |
-
"integrity": "sha512-
|
| 851 |
"license": "MIT",
|
| 852 |
"dependencies": {
|
| 853 |
-
"bytes": "3.1.2",
|
| 854 |
-
"http-errors": "2.0.
|
| 855 |
-
"iconv-lite": "0.7.0",
|
| 856 |
-
"unpipe": "1.0.0"
|
| 857 |
},
|
| 858 |
"engines": {
|
| 859 |
"node": ">= 0.10"
|
| 860 |
}
|
| 861 |
},
|
| 862 |
-
"node_modules/raw-body/node_modules/iconv-lite": {
|
| 863 |
-
"version": "0.7.0",
|
| 864 |
-
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
|
| 865 |
-
"integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==",
|
| 866 |
-
"license": "MIT",
|
| 867 |
-
"dependencies": {
|
| 868 |
-
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
| 869 |
-
},
|
| 870 |
-
"engines": {
|
| 871 |
-
"node": ">=0.10.0"
|
| 872 |
-
},
|
| 873 |
-
"funding": {
|
| 874 |
-
"type": "opencollective",
|
| 875 |
-
"url": "https://opencollective.com/express"
|
| 876 |
-
}
|
| 877 |
-
},
|
| 878 |
"node_modules/router": {
|
| 879 |
"version": "2.2.0",
|
| 880 |
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
|
|
|
| 10 |
"license": "MIT",
|
| 11 |
"dependencies": {
|
| 12 |
"axios": "^1.13.2",
|
| 13 |
+
"cors": "^2.8.5",
|
| 14 |
"dotenv": "^17.2.3",
|
| 15 |
+
"express": "^5.2.1",
|
| 16 |
+
"jsonwebtoken": "^9.0.3"
|
| 17 |
},
|
| 18 |
"engines": {
|
| 19 |
"node": ">=18.0.0"
|
|
|
|
| 50 |
}
|
| 51 |
},
|
| 52 |
"node_modules/body-parser": {
|
| 53 |
+
"version": "2.2.1",
|
| 54 |
+
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.1.tgz",
|
| 55 |
+
"integrity": "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw==",
|
| 56 |
"license": "MIT",
|
| 57 |
"dependencies": {
|
| 58 |
"bytes": "^3.1.2",
|
| 59 |
"content-type": "^1.0.5",
|
| 60 |
+
"debug": "^4.4.3",
|
| 61 |
"http-errors": "^2.0.0",
|
| 62 |
+
"iconv-lite": "^0.7.0",
|
| 63 |
"on-finished": "^2.4.1",
|
| 64 |
"qs": "^6.14.0",
|
| 65 |
+
"raw-body": "^3.0.1",
|
| 66 |
+
"type-is": "^2.0.1"
|
| 67 |
},
|
| 68 |
"engines": {
|
| 69 |
"node": ">=18"
|
| 70 |
+
},
|
| 71 |
+
"funding": {
|
| 72 |
+
"type": "opencollective",
|
| 73 |
+
"url": "https://opencollective.com/express"
|
| 74 |
}
|
| 75 |
},
|
| 76 |
"node_modules/buffer-equal-constant-time": {
|
|
|
|
| 169 |
"node": ">=6.6.0"
|
| 170 |
}
|
| 171 |
},
|
| 172 |
+
"node_modules/cors": {
|
| 173 |
+
"version": "2.8.5",
|
| 174 |
+
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
| 175 |
+
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
| 176 |
+
"license": "MIT",
|
| 177 |
+
"dependencies": {
|
| 178 |
+
"object-assign": "^4",
|
| 179 |
+
"vary": "^1"
|
| 180 |
+
},
|
| 181 |
+
"engines": {
|
| 182 |
+
"node": ">= 0.10"
|
| 183 |
+
}
|
| 184 |
+
},
|
| 185 |
"node_modules/debug": {
|
| 186 |
"version": "4.4.3",
|
| 187 |
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
|
|
|
| 328 |
}
|
| 329 |
},
|
| 330 |
"node_modules/express": {
|
| 331 |
+
"version": "5.2.1",
|
| 332 |
+
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
|
| 333 |
+
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
|
| 334 |
"license": "MIT",
|
| 335 |
"dependencies": {
|
| 336 |
"accepts": "^2.0.0",
|
| 337 |
+
"body-parser": "^2.2.1",
|
| 338 |
"content-disposition": "^1.0.0",
|
| 339 |
"content-type": "^1.0.5",
|
| 340 |
"cookie": "^0.7.1",
|
| 341 |
"cookie-signature": "^1.2.1",
|
| 342 |
"debug": "^4.4.0",
|
| 343 |
+
"depd": "^2.0.0",
|
| 344 |
"encodeurl": "^2.0.0",
|
| 345 |
"escape-html": "^1.0.3",
|
| 346 |
"etag": "^1.8.1",
|
|
|
|
| 560 |
}
|
| 561 |
},
|
| 562 |
"node_modules/http-errors": {
|
| 563 |
+
"version": "2.0.1",
|
| 564 |
+
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
|
| 565 |
+
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
|
| 566 |
"license": "MIT",
|
| 567 |
"dependencies": {
|
| 568 |
+
"depd": "~2.0.0",
|
| 569 |
+
"inherits": "~2.0.4",
|
| 570 |
+
"setprototypeof": "~1.2.0",
|
| 571 |
+
"statuses": "~2.0.2",
|
| 572 |
+
"toidentifier": "~1.0.1"
|
| 573 |
},
|
| 574 |
"engines": {
|
| 575 |
"node": ">= 0.8"
|
| 576 |
+
},
|
| 577 |
+
"funding": {
|
| 578 |
+
"type": "opencollective",
|
| 579 |
+
"url": "https://opencollective.com/express"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
}
|
| 581 |
},
|
| 582 |
"node_modules/iconv-lite": {
|
| 583 |
+
"version": "0.7.0",
|
| 584 |
+
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
|
| 585 |
+
"integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==",
|
| 586 |
"license": "MIT",
|
| 587 |
"dependencies": {
|
| 588 |
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
| 589 |
},
|
| 590 |
"engines": {
|
| 591 |
"node": ">=0.10.0"
|
| 592 |
+
},
|
| 593 |
+
"funding": {
|
| 594 |
+
"type": "opencollective",
|
| 595 |
+
"url": "https://opencollective.com/express"
|
| 596 |
}
|
| 597 |
},
|
| 598 |
"node_modules/inherits": {
|
|
|
|
| 767 |
"node": ">= 0.6"
|
| 768 |
}
|
| 769 |
},
|
| 770 |
+
"node_modules/object-assign": {
|
| 771 |
+
"version": "4.1.1",
|
| 772 |
+
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
| 773 |
+
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
|
| 774 |
+
"license": "MIT",
|
| 775 |
+
"engines": {
|
| 776 |
+
"node": ">=0.10.0"
|
| 777 |
+
}
|
| 778 |
+
},
|
| 779 |
"node_modules/object-inspect": {
|
| 780 |
"version": "1.13.4",
|
| 781 |
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
|
|
|
| 872 |
}
|
| 873 |
},
|
| 874 |
"node_modules/raw-body": {
|
| 875 |
+
"version": "3.0.2",
|
| 876 |
+
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz",
|
| 877 |
+
"integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==",
|
| 878 |
"license": "MIT",
|
| 879 |
"dependencies": {
|
| 880 |
+
"bytes": "~3.1.2",
|
| 881 |
+
"http-errors": "~2.0.1",
|
| 882 |
+
"iconv-lite": "~0.7.0",
|
| 883 |
+
"unpipe": "~1.0.0"
|
| 884 |
},
|
| 885 |
"engines": {
|
| 886 |
"node": ">= 0.10"
|
| 887 |
}
|
| 888 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 889 |
"node_modules/router": {
|
| 890 |
"version": "2.2.0",
|
| 891 |
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
package.json
CHANGED
|
@@ -20,9 +20,10 @@
|
|
| 20 |
"license": "MIT",
|
| 21 |
"dependencies": {
|
| 22 |
"axios": "^1.13.2",
|
|
|
|
| 23 |
"dotenv": "^17.2.3",
|
| 24 |
-
"express": "^5.1
|
| 25 |
-
"jsonwebtoken": "^9.0.
|
| 26 |
},
|
| 27 |
"engines": {
|
| 28 |
"node": ">=18.0.0"
|
|
|
|
| 20 |
"license": "MIT",
|
| 21 |
"dependencies": {
|
| 22 |
"axios": "^1.13.2",
|
| 23 |
+
"cors": "^2.8.5",
|
| 24 |
"dotenv": "^17.2.3",
|
| 25 |
+
"express": "^5.2.1",
|
| 26 |
+
"jsonwebtoken": "^9.0.3"
|
| 27 |
},
|
| 28 |
"engines": {
|
| 29 |
"node": ">=18.0.0"
|
src/server/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import express from 'express';
|
|
|
|
| 2 |
import path from 'path';
|
| 3 |
import { fileURLToPath } from 'url';
|
| 4 |
import { generateAssistantResponse, generateAssistantResponseNoStream, getAvailableModels, generateImageForSD, closeRequester } from '../api/client.js';
|
|
@@ -47,6 +48,7 @@ const endStream = (res) => {
|
|
| 47 |
res.end();
|
| 48 |
};
|
| 49 |
|
|
|
|
| 50 |
app.use(express.json({ limit: config.security.maxRequestSize }));
|
| 51 |
|
| 52 |
// 静态文件服务
|
|
|
|
| 1 |
import express from 'express';
|
| 2 |
+
import cors from 'cors';
|
| 3 |
import path from 'path';
|
| 4 |
import { fileURLToPath } from 'url';
|
| 5 |
import { generateAssistantResponse, generateAssistantResponseNoStream, getAvailableModels, generateImageForSD, closeRequester } from '../api/client.js';
|
|
|
|
| 48 |
res.end();
|
| 49 |
};
|
| 50 |
|
| 51 |
+
app.use(cors());
|
| 52 |
app.use(express.json({ limit: config.security.maxRequestSize }));
|
| 53 |
|
| 54 |
// 静态文件服务
|