1 Introduction
① For how to deploy WebGL with Nginx, please refer to another article: https://blog.csdn.net/Gpointy/article/details/131488559
② School experiments need to be connected to the iLab platform of the experiment space, and their interfaces need to be called, such as: http:/ /www.ilab-x.com/open/api/v2/user/validate?
2. Questions
After the experiment is packaged and deployed on Nginx, it starts to report cross-domain:
3. Reason
I consulted the technicians in the experimental space by phone, and told them that there would be cross-domain access to their interfaces directly in the browser, for security reasons.
4. Solutions
① Use Nginx for request forwarding
Change all the places in Unity that call the iLab platform interface to the server’s public network IP + port, such as http://11.12.13.14:8080/open/api/v2/user/validate?, package, Nginx Add the following configuration:
it can successfully solve the cross-domain problem
② Write a backend (it is theoretically feasible, but I haven’t tried it).
Write a java backend project and deploy it to the server. Unity calls the java interface, and httpClient is used in the java interface to call the iLab platform. , is also feasible