Serverless react app doesn't proxy to all API routes

So, we’re having a bit of a bizarre issue.

We have a react app and a backend app. Both are deployed with serverless and the react app proxies API requests to serverless. So far so good, except a couple of routes don’t in fact get proxied to serverless all the time. All API routes are under /api.

When the routes get fetched from react the result is html code for the react app (similar to hitting /index or /home or another route). When we directly access the route in the browser it correctly proxies through to the API (even if the cookie somehow doesn’t get sent and we get a 401 back). When hitting the proxy endpoints with Postman it works as it should.

I’ve tried setting the frontend up with Netlify and it proxies correctly – except these specific endpoints now return a 403 with the text “User is not authorized to access this resource”. Might it be a problem with cloudfront?

/Magnus