I'm trying to host a static react website on an AWS S3 bucket with CloudFront as a front-end.
Additionally the front-end uses an API which runs as a service on a seperate server with a connected domain.
However, when I go to my static s3 website to test it out, I can see in the developer console that all API calls from the bucket to the API are rewritten with the buckets own URL so it's using it own URL instead of the API's URL.
The API url is defined in the environment variables so my first thought was the environment variables are not defined during build. I printed the output of all the environment variables doing the build and they're all correct.
I was looking at a stackoverflow post (react router doesn't work in aws s3 bucket) but unfortunately it didn't help.
Any help or advice would be greatly appreciated.
EDIT My static website hosting settings: