I'm using express js for the REST interface of my application, on node js.
I'm also using jQuery Mobile for my client side pages.
I'm using redirect to change pages if the user tried to enter a location they're not allowed or can't access.
For some reason the url doesn't change, and as a result it doesn't load the css and js files.
I read in another place hat this is happening because of jQuery Mobile and they suggested to use rel=external
.
I don't know how to use it together with the express interface.
Any suggestions to comments on my problem?
I'm guessing you're sending a POST request and trying to redirect server-side, like so:
app.post('/location', function(req, res) {
if (!allowed) {
res.redirect('/otherpage');
} else {
// do stuff
}
});
You can't redirect to another page on a POST request. But you can send a redirect location with res.send({ redirect: '/otherpage' })
, and then have the frontend do the work, something like:
if (res.redirect) {
document.location.href = res.redirect;
}