This is a quite convoluted issue but maybe I'm missing something that is more general and not strictly related to my specific context.
Long story short: I have a CORS error when I make an http request from my Unity App (WebGL build) which is embedded in a react app BUT I have not this error if I simply use the Unity App (with a local web server).
I don't understand what's going on, the http request in both cases comes from an app served by a localhost
.
More details:
I've built a WebGL Unity App, this app runs fine with a local web server (http://127.0.0.1:8887/)
, in particular it fetches some jpg from the web when I mouse over a specific game object:
In the bottom-right
square you can see the result of this call:
new HTTPRequest(new Uri(tree.ImageURL));
where tree.ImageURL is https://nftimages.s3.us-east-2.amazonaws.com/N8G-7V4.jpg
(by the way, I'm using this plugin to make HTTP requests)
Now, I embedded this Unity App inside a react project (created with create-react-app
) with react-unity-webgl:
Everything works fine except those requests:
I know what CORS
are but I don't understand why in the first case it works and why here it does not.
Can you give me an explanation?
How to solve this issue?
Thank you!