-
-
Notifications
You must be signed in to change notification settings - Fork 598
The request in Parse.Object.saveAll() does not have a reverse proxy #1945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for opening this issue!
|
Could you please complete the issue template (I've re-added the headlines) and ensure that you follow the checklist at the top? |
I already fix it, and very sorry about didn't follow the issue template, cause this is the first time I try to send the issue. |
No worries, thanks for reporting the issue. The template just helps others to easier understand the issue. In the steps to reproduce you are first querying |
sorry, it was |
Could you please correct the code and make sure it's complete? |
I corrected it. Here are some additions, where my parse server is set on port :4000/parse on docker, so you can see above that I use an nginx as a reverse proxy to /api -> :4000/parse |
Could you post the line from ParseObject.js:3047:34? |
The error show up on the batchReturned ... this line
so as you can see, if my parseUrl is 'http://192.168.1.1/api' and I use a reverse proxy to make this url to redirect on the Parse Server (this is setup on the docker url: '192.168.1.1:4000/parse'), and I can see the request is sending to the url 'http://192.168.1.1/api' and then turn into the 'https://192.168.1.1:4000/parse', but the getServerUrlPath() didn't know I was trying to use reverse proxy skill, so for example:
Sorry for my english is not very good so please forgive me :( if i didn't explain clearly |
Thanks for providing more details, let's see if someone in the community has an idea... |
Are you suggesting we can close this issue via #2503? |
I think a test case should be written first before we close. |
Sounds good, @roger28200901 would you want to write a test to verify that the issue has been fixed? |
@coderabbitai analyze issue |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed:
Length of output: 2159 🏁 Script executed:
Length of output: 20823 Let me examine the RESTController.ts implementation to understand how HTTP requests and redirects are handled. 🏁 Script executed:
Length of output: 11391 🏁 Script executed:
Length of output: 3484 🏁 Script executed:
Length of output: 1655 @mtrezza I've analyzed issue #1945, which involves batch requests failing when using Parse SDK with a reverse proxy setup. Issue UnderstandingThe problem occurs in the following configuration:
In batch requests, the SDK's // In ParseObject.ts
const requests = batch.map(obj => {
const params = obj._getSaveParams();
params.path = getServerUrlPath() + params.path;
return params;
}); This results in paths like Solution in PR #2503PR #2503, which was merged on April 23, 2025, replaced XMLHttpRequest with the Fetch API. This appears to fix the issue because:
The fix is already available in version 6.2.0-alpha.3 and later. RecommendationAs dplewis suggested, a test case would be valuable to verify this fix properly handles reverse proxy redirections with batch requests. This would ensure the solution is robust and works as expected. For users on older SDK versions, possible workarounds include:
Would you like me to help draft a test case to verify the fix? |
@coderabbitai write a test case for this |
Tip For best results, initiate chat on the files or code changes. A summary of the edits CodeRabbit can apply:
A plan of each step that CodeRabbit will take in order to execute the edits for each file (with inline rough draft snippets): ➕ src/__tests__/RESTController-test.jsWithin the existing describe('RESTController', ...) block, just before the closing });, insert a new it test case as follows: it('follows HTTP redirects for batch requests when using a custom SERVER_URL', async () => {
// Configure a reverse-proxy style SERVER_URL
CoreManager.set('SERVER_URL', 'http://test.host/api');
// Prepare a minimal batch payload
const batchData = {
requests: [{
method: 'POST',
path: '/classes/TestObject',
body: { foo: 'bar' }
}]
};
// First response: 301 redirect to /parse/batch; second: successful response
mockFetch(
[
{ status: 301, response: {} },
{ status: 200, response: { success: true } }
],
{ location: 'http://test.host/parse/batch' }
);
// Issue the batch request
const result = await RESTController.request('POST', 'batch', batchData);
// We expect two fetch calls: one to the original URL, then one to the Location header
expect(fetch.mock.calls.length).toBe(2);
expect(fetch.mock.calls[0][0]).toEqual('http://test.host/api/batch');
expect(fetch.mock.calls[1][0]).toEqual('http://test.host/parse/batch');
// The final result should be the JSON from the second (successful) response
expect(result).toEqual({ success: true });
// Clean up the custom SERVER_URL
CoreManager.set('SERVER_URL', undefined);
}); This test verifies that when the Parse SDK encounters a 3XX redirect for a batch endpoint under a reverse-proxy‐style SERVER_URL, it reads the Location header and reissues the request to the correct path. Save the file and run the Jest test suite to ensure the new test passes and confirms correct redirect-following behavior. A summary of the context that CodeRabbit is considering across the codebase:
|
I opened a PR for this #2608 |
@mtrezza lol, it’s been more than a year. I switched the Parse JS architecture to Golang Mongoose about half a year ago. But I’m still happy to see this issue resolved. |
Creating a PR to execute the edits.... The changes have been created in this pull request: View PR |
Uh oh!
There was an error while loading. Please reload this page.
New Issue Checklist
Issue Description
I was wondering about the practical method behind Parse.Object.saveAll, If my Parse Server I want to redirect through Proxy
ex: 192.168.1.1/api -> 192.168.1.1:4000/parse then, here is the problem.
on the parse/lib/node/ParseObject.js line:2388
And here is the problem, After the above code, my input data format will be like this:
and then, as you can see the RESTController will send a axios POST for url -> 192.168.1.1/api/batch and then proxy server (nginx), will let the request send to the 192.168.1.1:4000/parse/batch, but in my requests body, the path only show it to /api/classes/{{className}}/{{objectId}}
, it wont through the nginx setting to let the redirect change to /parse/classes/{{className}}/{{objectId}}
Steps to reproduce
Actual Outcome
format : Parse Error: cannot route batch path: /api/classes/{{className}}/{{objectId}} { code: 111 }
real outcome: ParseError: cannot route batch path /api/classes/tests/6ab89f70-addf-11ed-b17e-f98dadf7fe5c at C:\Users.......\node_modules\parse\lib\node\ParseObject.js:3047:34 at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 111 },
.
.
.
Expected Outcome
Expected it can saveAll and the response won't fail
Environment
Nginx
Server
Database
Client
The text was updated successfully, but these errors were encountered: