I’m having trouble setting up a proxy for my Angular project to communicate with my Express backend. I’ve followed the instructions but it’s not working as expected.
hey, u tried clearing cache? check if the route in the express matches /api/data, since the backend may use /data instead. curious, what angular version are u working with?
yo, make sure ur express backend is actually running when u test. also, try changing the proxy config to ‘/api/*’ instead of just ‘/api’. sometimes that helps. and double-check ur backend route - it should be ‘/api/data’ not just ‘/data’ to match ur angular service
Have you checked if your Express backend is correctly handling the ‘/api’ prefix? Sometimes the issue lies in how the backend routes are set up. Try modifying your Express routes to include the ‘/api’ prefix, like this:
app.get(‘/api/data’, (req, res) => {
// Your data handling logic here
});
Also, ensure your Express app is using body-parser middleware correctly if you’re sending POST requests. If the problem persists, try adding a ‘changeOrigin’ flag to your proxy config: