Redirects with react-router pages and api?

Hello

Is there possibility to add wildcard to page redirects and api to get all pages to redirect /index.html except /api*

What I tried to do:

/*  /index.html  200
/api/*  https://not-real.cloudfront.net/api/:splat  200

This renders /api/* to be redirected to react-router.

Tried also other way:

/api/*  https://not-real.cloudfront.net/api/:splat  200
/*  /index.html  200

Also redirects /api/* to react-router.

I had to add all routes manually, this works as I want but remembering to add all routes is error prone.

/login /index.html 200
...
/privacy /index.html 200
/register* /index.html 200
...
/api/*  https://not-real.cloudfront.net/api/:splat  200

@Tommi_Taskinen The second one that you show should have worked.

The reason the first one wouldn’t work is because of:
https://docs.netlify.com/routing/redirects/#rule-processing-order

The redirects engine will process the first matching rule it finds, reading from top to bottom.
Rules in the _redirects file are always processed first, followed by rules in the Netlify configuration file.

Tried again and it did work now! Thank you!