Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,44 @@ app.UseCors(builder =>
.AllowAnyHeader()
);
```

### setup proxy for react frontend to communicate with dotnet backend

#### Basic Configuration
Add a proxy field to your React app's package.json to handle API calls to the .NET backend:

```json
{
"name": "your-react-app",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:5000",
"dependencies": {
// ... your dependencies
}
}
```

This proxy configuration allows your React app (running on port 3000) to make API calls to your .NET backend (running on port 5000) without CORS issues during development.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the proxy should come after setting up the backend application

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've moved the proxy section to appear after the .NET backend setup instructions (after the CORS configuration section). Commit 7190ad0


#### Advanced Configuration
For more complex proxy scenarios, you can create a setupProxy.js file in the src folder:

```javascript
const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
```

Note: You'll need to install http-proxy-middleware if using setupProxy.js:
```zsh
npm install --save-dev http-proxy-middleware
```