I have an api hosted on AWS’s ECS. I am using Wix as the front end. let response = await fetch(url) works fine until I publish for production. I get the following error:
createConsoleProxy.ts:47 TypeError: Failed to fetch
at eval (active$wBiEvent.js:56:19)
at eval (c1dmp.js:48:3)
at s (react-velo.esm.js:11:12552)
at Generator.eval [as _invoke] (react-velo.esm.js:11:12552)
at Generator.eval [as next] (react-velo.esm.js:11:12552)
at A (react-velo.esm.js:11:12552)
at i (react-velo.esm.js:11:12552)
at eval (react-velo.esm.js:11:12552)
at new Promise (<anonymous>)
at eval (react-velo.esm.js:11:12552)
(anonymous) @ createConsoleProxy.ts:47
eval @ active$wBiEvent.js:56
eval @ c1dmp.js:68
Promise.catch
eval @ c1dmp.js:48
s @ react-velo.esm.js:11
eval @ react-velo.esm.js:11
eval @ react-velo.esm.js:11
A @ react-velo.esm.js:11
i @ react-velo.esm.js:11
eval @ react-velo.esm.js:11
eval @ react-velo.esm.js:11
r @ c1dmp.js:7
n @ c1dmp.js:7
eval @ c1dmp.js:16
eval @ corvidEvents.js:73
(anonymous) @ registerEvent.ts:51
(anonymous) @ clientWorker.ts:157
n @ comlink.ts:312
My research leads me to believe this is a CORS issue that is resolved by moving my fetch requests to the back end of Wix. When I do that I get his error:
request to https://App-load-balancer-one-XXXXXXXXXXXXXX.amazonaws.com:XXX/getUser failed, reason: Hostname/IP does not match certificate's altnames: Host: app-load-balancer-one-XXXXXXXXXXXXXX.amazonaws.com. is not in the cert's altnames: DNS:mydomain.com
It seems the load balancer is not recognizing my website anymore. What is the correct way to use my api?