header (cURL) 中的标记与 Express.js Node.js
Token in header (cURL) with Express.js Node.js
所以,我想在我的项目中使用这段代码:
var allowCrossTokenHeader = function(req, res, next) {
res.header("Access-Control-Allow-Headers", "token");
};
但是它不工作,服务器挂起并且不工作,如果我评论这段代码,服务器工作正常。我需要检查对我的 RESTful api 的每个请求中的令牌,知道该怎么做吗?
您需要调用 next()
才能继续堆栈中的下一个中间件。
var allowCrossTokenHeader = function(req, res, next) {
res.header("Access-Control-Allow-Headers", "token");
next();
};
If the current middleware does not end the request-response cycle, it must call next() to pass control to the next middleware, otherwise the request will be left hanging.
所以,我想在我的项目中使用这段代码:
var allowCrossTokenHeader = function(req, res, next) {
res.header("Access-Control-Allow-Headers", "token");
};
但是它不工作,服务器挂起并且不工作,如果我评论这段代码,服务器工作正常。我需要检查对我的 RESTful api 的每个请求中的令牌,知道该怎么做吗?
您需要调用 next()
才能继续堆栈中的下一个中间件。
var allowCrossTokenHeader = function(req, res, next) {
res.header("Access-Control-Allow-Headers", "token");
next();
};
If the current middleware does not end the request-response cycle, it must call next() to pass control to the next middleware, otherwise the request will be left hanging.