I’d like to send POST and GET requests to an external server in my PlayCanvas script, to load some additional data at runtime. Unfortunately, I cannot figure out how.
Unfortunately, the project I am working on is private. I can set up an empty project to illustrate what I’m doing if that helps. In the meantime, this is the code I am trying to run:
I just noticed right now that I’m getting a CORS error in the console that I missed before. Here’s the error message:
“Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (url). (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).”
Do you know how I can prevent this from happening? I assume I need to do something on the PlayCanvas side, since I do not have control over the server I’m attempting to connect to.
If it’s a public API, it should be fine. A CORs error suggests that it isn’t public or that the API is expected to be ran from a server and not on the client.
We’re using Directus to store our data. We’re letting them host it (not the open source version), so I don’t think I have access to any of the php configuration. Is this something that has to be done serverside, then?
Edit: the actual URL I’m calling is “https://catatonic–eyesync.directus.io/api/1.1/auth/request-token” (catatonic–eyesync is our project name)