Redirects for relative URL's not working

Hi,

I’m having trouble with redirects to a relative URL on the web version of Postman.

I have a NodeJS Express server using express-generator, and I’m trying to redirect http://localhost:3000/redirect/page to http://localhost:3000/redirect:

This is my routes/index.js using express-generator:

var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.get('/redirect/page', function (req, res, next) {
  res.redirect('.');
});

router.get('/redirect/', function (req, res, next) {
  res.send("Redirected page");
});


module.exports = router;

The redirect works perfectly in the browser, but Postman redirects to http://localhost:3000/redirect/. with a period at the end, which returns a 404.

The issue still persists if the redirect is modified to res.redirect('./asdf'); the browser redirects to http://localhost:3000/redirect/asdf but Postman redirects to http://localhost:3000/redirect/./asdf

This seems like an issue with Postman, or is there anything I’m doing wrong on my end?
Thanks in advance!

Hi, is there a solution for this issue? (Prevent periods at the beginning of relative redirects from being interpreted as part of the URL) Please let me know if I can clarify anything or provide more info!

The issue you’re experiencing with redirects to relative URLs in Postman might be related to how Postman handles relative URLs. Instead of using a relative URL like ‘.’, you can try using the full URL ‘http://localhost:3000/redirect/’ for the redirect. This should ensure consistent behavior between the browser and Postman.

So your code would be modified as follows:

router.get('/redirect/page', function (req, res, next) {
  res.redirect('http://localhost:3000/redirect/');
});

Give this a try and see if it resolves the problem in Postman.
You may also validate your test on any online tool, such as the redirect check tool along with the redirect chain.

I still having this problem. There is a plan to fix this?