Home > database >  Express.js doesn't allow more than 6 requests. How do I fix this?
Express.js doesn't allow more than 6 requests. How do I fix this?

Time:11-04

I am working on a website where the person has to login first. On login, I make a fetch POST request to an endpoint defined in the server. When I login, and logout 6 consecutive times, i.e. login - logout - login - logout .. at the 6th time, I logout, and can't login again. The server doesn't accept anymore requests from the client until I refresh the browser, and then it works for 6 more times.

I've read that there is a 5 requests limit imposed on HTTP requests that are not consumed, even though many people said this limit has been removed. I am not using the HTTP module. I am creating my endpoints on the express instance.

Here's a snippet of two of my endpoints:

const app = express();

app.get('/', (req, res) => {
    res.json(getPost('all'))
})

app.post('/register/:user', async (req, res)=>{
   addUser(req.params.user)

})

Can anybody tell me how do I fix this issue? Do I try to increase the number of allowed requests ..? Do I "consume" the requests? How do I do that?

CodePudding user response:

Add a response to your post request.

app.post('/register/:user', async (req, res)=>{
   addUser(req.params.user); // this function doesn't respond to the request
   res.sendStatus(200); // something like this does!
})
  • Related