Edit and save json file with a script (not to local storage, but to the json file)

Here is the code, I want to prompt the user with a window alert asking to enter a username, if one already exists in the json with a password alert it already exists, otherwise open new alert for entering password, once both have been enteres save the account name and password to the json in the editor. Is this possible without a server?

In theory this should work but https://api.playcanvas.com/classes/Engine.Http.html#post.post-1 but I ran into issues after publishing with CORS (Cross-Origin Resource Sharing) where the site running on https://playcanv.as couldn’t update the json file on AWS since they are on different domains and I don’t think CORS on AWS was setup to allow that.

I kept getting errors like this:
Access to XMLHttpRequest at ‘https://s3-eu-west-1.amazonaws.com/apps.playcanvas.com/2821ceb0/files/assets/183592002/1/wrtcInfo.json?t=25bcf6655d266536cf0a080bef6a1e23&ts=1957.2999999970198’ from origin ‘https://playcanv.as’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

1 Like