AXCWG 3 сар өмнө
parent
commit
5539952a36
1 өөрчлөгдсөн 7 нэмэгдсэн , 1 устгасан
  1. 7 1
      main.js

+ 7 - 1
main.js

@@ -478,7 +478,7 @@ app.post("/ncm/url", function (req, res) {
         return
     }
 
-    if (req.body.id !== undefined && req.body.kind !== undefined) {
+    if (!req.body.id && !req.body.kind) {
         try {
             let id = req.body.id
             fetch(ncmAPIUrl + "/song/download/url/v1?id=" + id + "&level=hires", {
@@ -487,6 +487,12 @@ app.post("/ncm/url", function (req, res) {
                 }
             }).then(async result => {
                 if (result.status === 200 || result.status === 304) {
+                    try{
+                        await result.json()
+                    }catch (e){
+                        res.status(500).header("Access-Control-Allow-Origin", "*").end("格式错误");
+                        return
+                    }
                     let result_json = await result.json()
                     if (result_json.data.url !== null) {
                         let infos = await (await fetch(ncmAPIUrl + "/song/detail?ids=" + id)).json();