Can't seem to get setupProxy.js working with Duende ASP.NET Core BFF and TypeScript React project

1.3k views Asked by At

I can't seem to get the proxying to work for local development when trying to set up a Duende BFF with ASP.NET Core 6 and a TypeScript version of create react app.

Here's the repo I've been working in: https://github.com/dahlsailrunner/duende-bff-react-typescript

It's based on the sample from Duende which works fine: https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v6/BFF/ReactBffSample

I'm simply trying to get a new version of the same thing that uses the TypeScript version of React.

If I leave the ClientApp/src/setupProxy.js file named as-is, the React app seems to build, but it never loads in the browser (the output from the react scripts all seems fine and it says it should be in the browser, but I always get "connection refused". This remains true even if I comment out every line in setupProxy.js.

If I rename the file in any way (make it a .ts file, or add -bak to it), everything loads fine on the site but the proxy to the backend/BFF doesn't work.

I've tried adding src/setupProxy.js to the exclude list in tsconfig.json as mentioned as a workaround here.

I'm guessing I'm missing something simple but just haven't been able to see it yet.

1

There are 1 answers

1
Erik Dahl On

Wow - it turns out that the only problem from the code was that the version of http-proxy-middleware npm package was too current. Downgrading it to "http-proxy-middleware": "^0.19.1" did the trick - no other changes needed.