Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
HTTP retry
const express = require('express');
const app = express();
app.get('/hello', (req, res) => {
console.log('HANDLING REQUEST');
res.setHeader('content-type', 'application/json');
res.flushHeaders(); // `flushHeaders` to prevent http client from retrying and therefore invoking this handler multiple times.
app.listen(9000, () => {

This comment has been minimized.

Copy link

@nfcampos nfcampos commented Aug 12, 2020

With POST, and without flushHeaders (request done using fetch in Chrome console) the browser does not repeat the request and HANDLING REQUEST is printed only once)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment