Hi, just checking, but I was running a NodeJS site through an SEO test tool and saw it said all redirects done were 302 temporary vs 301 permanent, is there anything that can be done to alter this behaviour, to rather choose 301 instead.
I managed to work around it by editing the routes.js file from
/*FROM*/
if (redirect) {
app.get(path, (req, res) => res.redirect(redirect));
}
/*TO*/
if (redirect) {
app.get(path, (req, res) => res.redirect(301, redirect));
}
Edit, I noted that Server Side redirects were doing the same thing, defaulting to 302 redirects and not allowing me the option to change to 301, so also edited the core.js
file
/*FROM*/
redirect: function (options) {
this.res.redirect(this.parse(options.url));
},
/*TO*/
redirect: function (options) {
this.res.redirect(301, this.parse(options.url));
},
I found this quick checking tool to help https://www.redirect-checker.org/index.php
@patrick or @George, is this a bad idea for any other reason?
It depends on the intent of the redirect. User is not logged in and attempts to access /dashboard? 302 temporary redirect to /login
Old static page link to point to newer ones? 301 permanent redirect
Exactly, which is why it would be better if both the client and server side had the option to switch between 301 or 302, by making the alterations as I have in the main Wappler files, means now I am stuck with either all 301, or all 302.
Considering we do not have htaccess file availability in node, it’s pretty important when taking over websites from older development.
This should be an easy fix for the Wappler team. They just need to add a new field to the Redirect step and change the code you’ve changed to get the option you picked
/*FROM*/
redirect: function (options) {
this.res.redirect(this.parse(options.url));
},
/*TO*/
redirect: function (options) {
this.res.redirect(this.parse(options.code) || 302, this.parse(options.url));
},
Maybe @patrick
Just checking if Wappler is considering adding an option to switch between 301 or 302 redirects.
Looking forward to having this option, I just finished another project that will also need a whole bunch of redirects for Google.