Hello, I have already read Unity Documentation and this thread.
Yet I still have several concern about a Unity WebGL build of mine.
In fact, I am trying to make requests from our website to our server API. For instance, my WebGL content is located on server.fr and we are making a GET request to server.fr. I’m using Unity’s tool UnityWebRequest to perform this. Nevertheless, when I have fully built myWebGL content and exported it on server.fr, those requests are forbidden. I still can’t figure out why this is not working and I’m sure my requests are correctly implemented on my server API.
Do you know how to solve this problem ?
if you are hosting on the same server (including subdomain) which you want to access, there should not be restrictions. Do you see any errors in the browser console?
If you are familiar with XMLHttpRequest, then you can try to debug this issue outside of the Unity code. Just perform the request to the very same resource directly from the JavaScript on your index page, and check if you still get 403. Also, check the network profiler in the browser, it will give you a lot of important information, check if your request is preflighted and, if possible, attach the screenshot.
If you can not access the resource from pure JavaScript using XMLHttpRequest (assuming that the resource starts with http:// which part you would not have any reason to censor), then I would assume that it is either a cross-origin request, or the resource is not available from the browser address line (which you can try).
I would also recommend you to use the browser network profiler, which is accessible from the Network tab near the Console tab in most browsers, it gives additional information, i.e. about preflighted requests etc. The network profiler also gives you information about the full resource path being accessed, in case if you are using an incorrect relative path.
Thank you so much for your help Alex. It turns out that our problem was indeed a server restriction, since we are not working directly on the server, there has been some misunderstanding, and now our request is working effectively !