Http-proxy-middleware: Proxy not working with preflight OPTIONS request of the browser

Created on 4 Jan 2018  路  1Comment  路  Source: chimurai/http-proxy-middleware

Proxy not working with preflight OPTIONS request of the browser. It will run into a timeout with BadRequestError: request aborted.

It is working as intended if I initiate directly a POST request with e.g. "Postman".

Setup

app.use(cors());
app.use(bodyParser.json());
app.use(
        '/xyz',
        proxy({
            target: 'http://localhost:8082',
            changeOrigin: true,
        })
    );

Any ideas or possible solution to this problem?

Most helpful comment

Looks like it is related to the bodyParser.... Moved the proxy on top and it works.

>All comments

Looks like it is related to the bodyParser.... Moved the proxy on top and it works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mshindal picture mshindal  路  4Comments

gajus picture gajus  路  8Comments

kimmobrunfeldt picture kimmobrunfeldt  路  5Comments

ubreddy picture ubreddy  路  5Comments

minhduchcm picture minhduchcm  路  7Comments