mengungkapkan pengalihan ke URL
app.get("/where", (req, res) => {
res.status(301).redirect("https://www.google.com")
}) //You need to include the status (301)
Batman
app.get("/where", (req, res) => {
res.status(301).redirect("https://www.google.com")
}) //You need to include the status (301)
window.location.href = "http://mywebsite.com/home.html";
app.get('/', (req, res) => {
res.redirect('/about');
})
res.redirect('/foo/bar')
res.redirect('http://example.com')
res.redirect(301, 'http://example.com')
res.redirect('../login')
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!'));