-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Labels
state:releasedReleased as stable versionReleased as stable versionstate:released-betaReleased as beta versionReleased as beta versiontype:featureNew feature or improvement of existing featureNew feature or improvement of existing feature
Description
New Feature / Enhancement Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
Current Limitation
Currently, context can only be used by injecting a _context key/value into the body when using REST. This is problematic for SDK's that encode objects without modifying the body like the Swift SDK. This was originally discussed on community.parseplatform.org.
Feature / Enhancement Description
Currently, context is setup to be accepted in the header, but doesn't have an actual header:
parse-server/src/middlewares.js
Lines 25 to 39 in 9ea355b
| export function handleParseHeaders(req, res, next) { | |
| var mount = getMountForRequest(req); | |
| var info = { | |
| appId: req.get('X-Parse-Application-Id'), | |
| sessionToken: req.get('X-Parse-Session-Token'), | |
| masterKey: req.get('X-Parse-Master-Key'), | |
| installationId: req.get('X-Parse-Installation-Id'), | |
| clientKey: req.get('X-Parse-Client-Key'), | |
| javascriptKey: req.get('X-Parse-Javascript-Key'), | |
| dotNetKey: req.get('X-Parse-Windows-Key'), | |
| restAPIKey: req.get('X-Parse-REST-API-Key'), | |
| clientVersion: req.get('X-Parse-Client-Version'), | |
| context: {}, | |
| }; |
Adding a new header X-Parse-Cloud-Context will address the issue.
Example Use Case
Using REST:
parse-server/spec/CloudCode.spec.js
Lines 2537 to 2548 in 0c23bfd
| const req = request({ | |
| method: 'POST', | |
| url: 'http://localhost:8378/1/classes/TestObject', | |
| headers: { | |
| 'X-Parse-Application-Id': 'test', | |
| 'X-Parse-REST-API-Key': 'rest', | |
| 'X-Parse-Context': '{"key":"value","otherKey":1}', | |
| }, | |
| body: { | |
| foo: 'bar', | |
| }, | |
| }); |
Alternatives / Workarounds
No workarounds for using context in the header. Will have to modify the body with _context like the other SDKs.
3rd Party References
Metadata
Metadata
Assignees
Labels
state:releasedReleased as stable versionReleased as stable versionstate:released-betaReleased as beta versionReleased as beta versiontype:featureNew feature or improvement of existing featureNew feature or improvement of existing feature