Answers for "express .redirect"

50

express js redirect to url

window.location.href = "http://mywebsite.com/home.html";
Posted by: Guest on July-18-2019
2

express redirect to url

app.get("/where", (req, res) => {
   res.status(301).redirect("https://www.google.com")
}) //You need to include the status (301)
Posted by: Guest on October-19-2021
-1

express url redirect

const app = require('express')();

// The `res.redirect()` function sends back an HTTP 302 by default.
// When an HTTP client receives a response with status 302, it will send
// an HTTP request to the URL in the response, in this case `/to`
app.get('/from', (req, res) => {
  res.redirect('/to');
});
app.get('/to', (req, res) => res.send('Hello, World!'));
Posted by: Guest on June-12-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language