question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doing a res.redirect() in the API adds a '#' to the end of the URL

See original GitHub issue

Bug report

Describe the bug

In an API route, doing a res.redirect(302, '/somepath') always adds a # to the end of the URL. For example:

res.redirect(302, '/allocation')

becomes: /allocation#

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Create an API route and do a res.redirect() within the function.

Expected behavior

I expect the URL to not contain a ‘#’ sign.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: Mac OS Big Sur
  • Browser: Chrome
  • Version of Next.js: 10.0.3
  • Version of Node.js: node:14.15.0-alpine
  • Deployment: next

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jamesmosiercommented, Dec 7, 2020

Hi @nodeworks. I wasn’t able to reproduce 🤔 I tried redirecting to both a page and another api route:

export default (req, res) => {
  res.redirect(302, '/api/test')
}

and

export default (req, res) => {
  res.redirect(302, '/test-page')
}

Is there any other info that might help track this down?

1reaction
erhankaradenizcommented, Dec 9, 2020

Sure, not success guaranteed, but I’d like to look and see if I can help. I’ll send an email.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express.js res.redirect() Function - GeeksforGeeks
The res.redirect() function redirects to the URL derived from the specified path, with specified status, a integer (positive) which ...
Read more >
Redirects With Express - Mastering JS
The res.redirect() function lets you redirect the user to a different URL by sending an HTTP response with status 302.
Read more >
How to redirect user's browser URL to a different page in ...
You can use res.render() or res.redirect() method to redirect to another page using ... var navigator = require('web-midi-api'); var app = express(); ...
Read more >
res.redirect() - Sails.js
return res.redirect(url);. Or: return res.redirect(statusCode, url);. Arguments. # ...
Read more >
Creating Redirects With Nuxt - Josh Deltener
In this post we'll explore different ways of making redirects in your Nuxt application. ... writeHead(301, { location }) res.end() } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found