Javascript 强制令牌刷新,但令牌仍已过期?

Javascript 强制令牌刷新,但令牌仍已过期?,javascript,node.js,firebase,firebase-authentication,firebase-admin,Javascript,Node.js,Firebase,Firebase Authentication,Firebase Admin,这是我的代码,在我使用Firebase登录后设置令牌^ 以下是在服务器上检查令牌的代码: var app = angular.module('app', ['firebase']); const setAppCookie = () => firebase.auth().currentUser.getToken(true).then(token => { Cookies.set('token', token, { domain: window.location.

这是我的代码,在我使用Firebase登录后设置令牌^

以下是在服务器上检查令牌的代码:

var app = angular.module('app', ['firebase']);
const setAppCookie = () => firebase.auth().currentUser.getToken(true).then(token => {
    Cookies.set('token', token, {
        domain: window.location.hostname,
        expire: 1 / 24,
        path: '/',
        secure: true
    });
});
const unsetAppCookie = () => Cookies.remove('token', {
    domain: window.location.hostname,
    path: '/',
});
app.factory("Auth", ["$firebaseAuth", function ($firebaseAuth) {
    return $firebaseAuth();
}]);
app.controller("ctrlHead", ["$scope", "Auth", "$window", function ($scope, Auth, $window) {
    $scope.auth = Auth;
    $scope.auth.$onAuthStateChanged(function (firebaseUser) {
        if (firebaseUser) {
            setAppCookie();
            localStorage.setItem("authenticated", JSON.stringify("yay!"));
        } else {
            localStorage.setItem("authenticated", JSON.stringify(null));
        }
    });
    $scope.authenticated = JSON.parse(localStorage.getItem("authenticated"));
}]);
虽然我将令牌设置为强制刷新,但我无法登录,并且总是出现以下错误:

{错误:Firebase ID令牌已过期。请从客户端应用获取新令牌,然后重试。有关如何检索ID令牌的详细信息,请参阅


发生了什么事?我做错了什么?

出于某种原因,它似乎在本地工作。但在prod中不起作用。这非常奇怪,因为它昨天在prod中工作。我一定是在什么地方做了更改:/可能是缓存的令牌?ID令牌在60秒后过期。@HiranyaJayathilaka就是这样。@Programmer你是如何解决问题的问题?我面临着同样的问题。出于某种原因,它似乎在本地工作。但在prod中不起作用。这非常奇怪,因为它昨天在prod中工作。我一定是在某处做了一些更改:/可能是缓存的令牌?ID令牌在60秒后过期。@HiranyaJayathilaka就是这样。@Programmer你是如何解决问题的?我面临的同样的问题。
router.get('/page', function(req, res, next) {
    global.page_name = current;

    const { token } = req.cookies;

    if (!token || token == undefined) {
            global.page_name = "...";

            res.redirect("/");
    }
    else {
        admin.auth().verifyIdToken(token)
        .then(decodedToken => {
        }).catch(err => {
            console.log(err);
                global.page_name = "...";

                res.redirect("/");
        });
    }  
});