MongoDB value not incrementing after incremented once MongoDB value not incrementing after incremented once mongoose mongoose

MongoDB value not incrementing after incremented once


In simple terms:

1. It is because of 301 Status Code for Redirect you are using.2. 301 Status Code represents a Permanent Redirect.3. The browser stores the main URL in the memory.4. The next time you request the short link from your browser, it gets the Original   URL from its memory and sends you there, without going through the Server.5. Since the request doesn't go through the server, the server fails to increment it.

Solution:

Change 301 (Permanent) Status code to 307 (Temporary) Status Code.

FILE: ShortLink/routes/urlShortner.jsChange the below linesLine 37:  res.writeHead(301, {Line 38:      Location: url.inputUrlLine 39:  });toLine 37:  res.writeHead(307, {Line 38:      Location: url.inputUrlLine 39:  });

I have also created a pull request to your Github Repo which you can verify.