Micro Redirect -
A redirect function for Zeit's micro
Firstly, install it:
npm install --save micro-redirect
Then import it like this:
const redirect = require("micro-redirect");
And use it the same you'd use Zeit's send:
module.exports = async (req, res) => {
const statusCode = 302;
const location = "http://github.com";
redirect(res, statusCode, location);
};
redirect(res, statusCode, location)
statusCode
is aNumber
with the HTTP redirect code, and must always be supplied.location
is aString
used to set the res header location, and must always be supplied.