diff --git a/src/Adapters/Files/GridStoreAdapter.js b/src/Adapters/Files/GridStoreAdapter.js index 22d5680d46..377c344c27 100644 --- a/src/Adapters/Files/GridStoreAdapter.js +++ b/src/Adapters/Files/GridStoreAdapter.js @@ -63,7 +63,7 @@ export class GridStoreAdapter extends FilesAdapter { } getFileLocation(config, filename) { - return (config.mount + '/files/' + config.applicationId + '/' + encodeURIComponent(filename)); + return (config.publicServerURLOrMount + '/files/' + config.applicationId + '/' + encodeURIComponent(filename)); } } diff --git a/src/Config.js b/src/Config.js index 4e599bde39..3d18ac6b5b 100644 --- a/src/Config.js +++ b/src/Config.js @@ -79,6 +79,11 @@ export class Config { get verifyEmailURL() { return `${this.publicServerURL}/apps/${this.applicationId}/verify_email`; } + + // provide the public server URL if the mount differs from how the parse server is accessed from outside + get publicServerURLOrMount() { + return this.publicServerURL !== '' ? this.publicServerURL : this.mount; + } }; export default Config; diff --git a/src/RestWrite.js b/src/RestWrite.js index ba1bfdca1c..295c7806c6 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -805,7 +805,7 @@ RestWrite.prototype.runAfterTrigger = function() { RestWrite.prototype.location = function() { var middle = (this.className === '_User' ? '/users/' : '/classes/' + this.className + '/'); - return this.config.mount + middle + this.data.objectId; + return this.config.publicServerURLOrMount + middle + this.data.objectId; }; // A helper to get the object id for this operation.