Hello!
I have a WEBGL project where I use Unity Multiplay API’S to allocate servers. The problem is that my API response is getting blocked by CORs.
I disabled CORs on my browser and it worked fine, how can I setup custom headers on the Unity multiplay servers?
We’re also having this issue.
Running the WebGL on localhost is fine at communicating with Game Server Hosting (Multiplay) REST API. However when we upload to a host providor we get an CORS restriction error in the browser console:
Access to fetch at 'https://services.api.unity.com/multiplay/servers/v1/projects/***/environments/***/servers' from origin 'https://ourdomain.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
The htaccess file:
Header add Access-Control-Allow-Origin "https://services.api.unity.com"
Header add Access-Control-Allow-Credentials "true"
Header add Access-Control-Allow-Headers "authorization, origin, user-token, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Header merge Vary Origin
</IfModule>
AddType application/wasm .wasm```
The 'servers' API request:
![9550888--1349731--upload_2023-12-28_11-42-54.png|714x933](upload://9b1OC0LojxJmnamsYVXLktGvrmv.png)
And response:
![9550888--1349734--upload_2023-12-28_11-45-11.png|738x818](upload://cy1PEeVRk9TIKclODki2O949ywu.png)
Help would be very much appretiated.
I’m also running into this issue!