Best practice for React SPA Proxy Settings

I am probably missing something in the documentation and my knowledge of React is lacking but I trying to ensure that I can develop locally and deploy and follow best practices.

Currently, the “proxy” for the React APP is configured in the package.json. Everything works fine developing locally.

I am building and deploying the solution using Docker (deployed to AWS AppRunner). The docker build runs RUN npm install && npm run build. How do I change the configuration so the build does not still proxy to localhost?

Some docs on the react-spa template home page.

You don’t need a proxy, when you create a production build with:

$ npm run build

It creates a production build of the React App into the .NET’s wwwroot/ folder, where it just gets deployed with your .NET App as normal.

Thanks!!

That makes sense. Ultimately, the issue I had was passing the wrong base URL to JsonServiceClient

Previous:

let baseUrl = packageConfig['proxy'];    //default in React SPA template for localhost

Fixed:

let baseUrl = '/';
1 Like