Registry
Eexpressjs avatar

expressjs/redirect-arg-order

Migrates usage of the legacy APIs `res.redirect(url, status)` to use the recommended argument order `res.redirect(status, url)`.

expressjs806 executions

  • transformation
  • migration
  • express
  • redirect
  • location
Connect a repo
npx codemod @expressjs/redirect-arg-order

Migrate legacy res.redirect(url, status)

Migrates usage of the legacy APIs res.redirect(url, status) to the new signature
res.redirect(status, url). This usage was deprecated in Express 4, in Express 5 you must use the new signature res.redirect(status, url).

Example

Migrating res.redirect(url, status)

The migration involves replacing instances of res.redirect(url, status) with res.redirect(status, url).

diff
app.get('/some-route', (req, res) => {
  // Some logic here
- res.redirect(url, status);
+ res.redirect(status, url);
});

References

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.