Answer the question
In order to leave comments, you need to log in
Why can't I redirect the client?
Hello. On the client, I create the following XMLHttpRequest:
const xhr = new XMLHttpRequest();
xhr.open('post', '/path', true);
xhr.setRequestHeader('x-redirect', 'true');
xhr.send();
app.post('/path', (req, res) => {
res.redirect('/exit');
});
Answer the question
In order to leave comments, you need to log in
Through AJAX, as far as I know, you cannot redirect the client, but if you send a request, and from the request get the page and replace the content, in addition, you can use the History API to change the URL.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question