Здесь я хотел бы избежать использования document.write (), так как это не рекомендуется ( Консольное сообщение : userLoginPost.js: 47 [Нарушение] Избегайте использования document.write (). ).Я просто хочу получить доступ к ссылке, защищенной маршрутом, гораздо лучше.Пожалуйста, помогите мне с этим.
//checkAuth middleware is verifying the JWT token received from client
app.get('/dashboard', checkAuth, (req, res) => {
res.sendFile(__dirname + '/views/app/dashboard.html');
});
$.ajax({
url: "http://localhost:3443/dashboard",
type: 'GET',
headers: {"Authorization": 'Bearer ' + Cookies.get('token') },
success: function(request){
console.log(request); //typeof request == string, request contains the source of http://localhost:3443/dashboard in string format.
window.location.href = this.url; //Here, the server is not receiving the token for verification so it throws back auth error
document.write(request); //it works
},
error: function(response){
console.log(response);
}
});