From f7f453cd46071a9d4a965f05197c776db3311841 Mon Sep 17 00:00:00 2001 From: Tom Fox Date: Tue, 1 Oct 2019 10:35:20 +0100 Subject: [PATCH 1/2] Add info about http redirects --- _includes/cloudcode/cloud-code-advanced.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/_includes/cloudcode/cloud-code-advanced.md b/_includes/cloudcode/cloud-code-advanced.md index eb8da2522..8463c5cbb 100644 --- a/_includes/cloudcode/cloud-code-advanced.md +++ b/_includes/cloudcode/cloud-code-advanced.md @@ -8,7 +8,7 @@ A simple GET request would look like: ```javascript Parse.Cloud.httpRequest({ - url: 'http://www.awesomewebsite.com/' + url: 'https://www.awesomewebsite.com/' }).then(function(httpResponse) { // success console.log(httpResponse.text); @@ -24,7 +24,7 @@ A GET request that specifies the port number would look like: ```javascript Parse.Cloud.httpRequest({ - url: 'http://www.awesomewebsite.com:8080/' + url: 'https://www.awesomewebsite.com:8080/' }).then(function(httpResponse) { console.log(httpResponse.text); }, function(httpResponse) { @@ -34,6 +34,19 @@ Parse.Cloud.httpRequest({ Valid port numbers are 80, 443, and all numbers from 1025 through 65535. +If your request is likely to be redirected, you can allow that with the `followRedirects: true` argument. + +```javascript +Parse.Cloud.httpRequest({ + url: 'https://www.awesomewebsite.com/', + followRedirects: true +}).then(function(httpResponse) { + console.log(httpResponse.text); +}, function(httpResponse) { + console.error('Request failed with response code ' + httpResponse.status); +}); +``` + ### Query Parameters You can specify query parameters to append to the end of the url by setting `params` on the options object. You can either pass a JSON object of key value pairs like: @@ -578,4 +591,4 @@ const config = await Parse.Config.get({useMasterKey: true}); const privateParam = config.get("privateParam"); ``` -By default, Parse Config parameters can be publicly read which may be undesired if the parameter contains sensitive information that should not be exposed to clients. A parameter can be made readable only with the master key by setting the `Requires master key?` property via the Parse Dashboard to `Yes`. \ No newline at end of file +By default, Parse Config parameters can be publicly read which may be undesired if the parameter contains sensitive information that should not be exposed to clients. A parameter can be made readable only with the master key by setting the `Requires master key?` property via the Parse Dashboard to `Yes`. From 43de405cab32598a4fe60da2759492a20178f994 Mon Sep 17 00:00:00 2001 From: Tom Fox Date: Tue, 1 Oct 2019 10:43:47 +0100 Subject: [PATCH 2/2] change explanation --- _includes/cloudcode/cloud-code-advanced.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/cloudcode/cloud-code-advanced.md b/_includes/cloudcode/cloud-code-advanced.md index 8463c5cbb..7a9f0bebb 100644 --- a/_includes/cloudcode/cloud-code-advanced.md +++ b/_includes/cloudcode/cloud-code-advanced.md @@ -34,7 +34,7 @@ Parse.Cloud.httpRequest({ Valid port numbers are 80, 443, and all numbers from 1025 through 65535. -If your request is likely to be redirected, you can allow that with the `followRedirects: true` argument. +By default, `Parse.Cloud.httpRequest` does not follow redirects caused by HTTP 3xx response codes, the `followRedirects: true` option can be used to change this. ```javascript Parse.Cloud.httpRequest({