Yotam
Yotam

Reputation: 10485

Redirecting user request, nodeJS

I'm building a little email server based on nodeJS (homework). When a user tries to login I check that he has an account and then redirect him to /user/userName. I set the response status to 201 Created, and then added a header Location: /user/userName

I checked in chrome's developer tools that the response was what I sent and it was, yet the location does not change. Any ideas why, or how to do it better?

Thanks

Upvotes: 0

Views: 202

Answers (1)

cjohn
cjohn

Reputation: 11660

The HTTP response code for a permanent redirect is 301, not 201. Your browser will not use the location header to redirect you with a 201. Before you change to 301, though, make sure you don't want a temporary redirect, or 302, instead!

Upvotes: 1

Related Questions