I am making a pure NodeJs server and am trying to redirect the user. However, changing the location header doesn't help. In Chrome, I see that the response header has location and the code is 201 (I tried it with other codes, too), but Chrome (and neither does Edge) doesn't redirect. What am I doing wrong? Here is how I am trying to redirect (I made it as a server so it is easier to test for you):
const http = require("http"); function requestHandler(req, res) { res.writeHead(201, { "Location": "/cats" }); } function listeningHandler() {} const app = http.createServer(requestHandler); app.listen(5000, listeningHandler);