CORS issue when using res.redirect()


I’m in the process of refactoring an Express.js API and its REST endpoints.

We are switching from app.get('creditCards',...) to app.get('/billing/cards',...). To make the transition easier, I want to simply add a res.redirect('/billing/cards') inside the creditCards endpoint.

On the client though, I get this error:

XMLHttpRequest cannot load http://localhost:3000/creditCards. The request was redirected to ‘http://localhost:3000/billing/card’, which is disallowed for cross-origin requests that require preflight.

How do I configure my CORS settings either on the API or on the client to allow this?