Browse Source

fix api response header

DIYgod 8 years ago
parent
commit
09aa61efe2
3 changed files with 5 additions and 1 deletions
  1. 1 1
      nodejs/routes/all.js
  2. 2 0
      nodejs/routes/bilibili.js
  3. 2 0
      nodejs/routes/get.js

+ 1 - 1
nodejs/routes/all.js

@@ -2,7 +2,7 @@ module.exports = function(req, res, next) {
     res.header('Access-Control-Allow-Origin', '*');
     res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
     res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
-    res.header('content-type', 'application/json; charset=utf-8');
+    res.header('Cache-control', 'no-cache');
 
     if (req.method == 'OPTIONS') {
         res.send(200);

+ 2 - 0
nodejs/routes/bilibili.js

@@ -5,6 +5,8 @@ var fetch = require('node-fetch');
 var parseString = require('xml2js').parseString;
 
 module.exports = function (req, res) {
+    res.header('content-type', 'application/json; charset=utf-8');
+    
     var ip = req.headers['x-forwarded-for'] ||
         req.connection.remoteAddress ||
         req.socket.remoteAddress ||

+ 2 - 0
nodejs/routes/get.js

@@ -4,6 +4,8 @@ var danmaku = require('../models/danmaku');
 var redis = require('../tools/redis');
 
 module.exports = function (req, res) {
+    res.header('content-type', 'application/json; charset=utf-8');
+
     var ip = req.headers['x-forwarded-for'] ||
         req.connection.remoteAddress ||
         req.socket.remoteAddress ||