Recommand · January 13, 2022 0

Localhost refuses to connect when I make setupProxy.js

I made my setupProxy.js to deal with a CORS issue:

const proxy = require('http-proxy-middleware');

module.exports = function (app) {
        proxy('/myUrl', {
            target: 'http://localhost:8090',
            changeOrigin: true

After I made it and run ‘npm start’ again, my browser says that localhost refuses to connect. If I delete setupProxy.js, I can connect to localhost, but the CORS policy blocks to connect with backend server.

Do you have any idea to connect to frontend, still using the setupProxy.js?