|
@@ -7,14 +7,14 @@ router.use(bodyParser.urlencoded({
|
|
|
router.use(bodyParser.json({ limit: '10mb' }));
|
|
|
|
|
|
// 跨域参数配置
|
|
|
-const allowCrossDomain = function (req, res, next) {
|
|
|
- res.header('Access-Control-Allow-Origin', '*');
|
|
|
- res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
|
|
|
- res.header('Access-Control-Allow-Headers', 'Content-Type');
|
|
|
- res.header('Access-Control-Allow-Credentials', 'true');
|
|
|
- next();
|
|
|
-};
|
|
|
-router.use(allowCrossDomain)
|
|
|
+// const allowCrossDomain = function (req, res, next) {
|
|
|
+// res.header('Access-Control-Allow-Origin', '*');
|
|
|
+// res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
|
|
|
+// res.header('Access-Control-Allow-Headers', 'Content-Type');
|
|
|
+// res.header('Access-Control-Allow-Credentials', 'true');
|
|
|
+// next();
|
|
|
+// };
|
|
|
+// router.use(allowCrossDomain)
|
|
|
|
|
|
function goWrong(response,msg){
|
|
|
response.status(500)
|
|
@@ -45,6 +45,20 @@ const psqlDB = require("../../psql.service");
|
|
|
* }
|
|
|
* @example
|
|
|
curl -X POST 'http://127.0.0.1:1337/api/psql/select' -H 'Content-Type: application/json' --data '{"sql":"SELECT * FROM \"_User\" limit 5","params":[1]}'
|
|
|
+ curl -X POST 'https://dev.fmode.cn/api/psql/select' -H 'Content-Type: application/json' --data '{"sql":"SELECT * FROM \"_User\" limit 5","params":[1]}'
|
|
|
+ let response = await fetch(`https://dev.fmode.cn/api/psql/select`, {
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/json"
|
|
|
+ },
|
|
|
+ body: JSON.stringify({"sql":"SELECT * FROM \"_User\" limit 5","params":[1]}),
|
|
|
+ method: "POST",
|
|
|
+ mode: "cors",
|
|
|
+ credentials: "omit"
|
|
|
+ });
|
|
|
+
|
|
|
+ let result = await response?.json();
|
|
|
+ console.log(result)
|
|
|
+
|
|
|
*/
|
|
|
|
|
|
router.post('/select', async function (req, response) {
|