Skip to content

Batch Request Problem when parse is served from folder behind reverse proxy #6980

@rhuanbarreto

Description

@rhuanbarreto

New Issue Checklist

Issue Description

Given I have a Parse Server Running on a local server, port 1337 (serverUrl: "http://127.0.0.1:1337/parse"), with publicServerURL different from the serverUrl (publicServerURL: "http://somedomain.com/backend/parse")
And this server is behind a reverse proxy (Nginx) forwarding the address http://somedomain.com/backend/ to this host running parse:

location ^~ /backend/ {
    proxy_pass http://parse-server-dns-name.com:1337/;
  }

When, inside of a cloud function, I do a Parse.Object.saveAll() (POST /parse/batch) with the following parameters:

{
  “requests”: [
    { “method”: “PUT”, “body”: { “type”: “Test2" }, “path”: “/parse/classes/Task/lVEd1AHl08" }
  ]
}

Then I should get the object updated, but Instead an error comes in the log

cannot route PUT /lVEd1AHl08

Related issue

This issue is probably happening because of #3042

In this line

const newPath = path.posix.join('/', localPath, '/', requestPath.slice(publicPath.length));

It tries to reconcile the difference between the 2 addresses, but it makes some confusion. In my case should route to the serverURL, but it's trying to use something different.

Environment

Server

  • Parse Server version: 4.3.0
  • Operating system: Linux (Docker)
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Local (self hosted)

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: v4.2.9
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): Local (Self Hosted)

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): JS SDK
  • SDK version: 2.15.0

Logs

{“method”:“POST”,“url”:“/parse/batch”,“headers”:{“user-agent”:“node-XMLHttpRequest, Parse/js2.15.0 (NodeJS 12.19.0)“,”accept”:“*/*“,”content-type”:“text/plain”,“host”:“127.0.0.1:1337”,“content-length”:“241”,“connection”:“close”},“body”:{“requests”:[{“method”:“PUT”,“body”:{“type”:“Test2"},“path”:“/parse/classes/Task/lVEd1AHl08"}]}},
error: Parse error: cannot route PUT /lVEd1AHl08 {“code”:107,“stack”:“Error: cannot route PUT /lVEd1AHl08\n    at PromiseRouter.tryRouteRequest (/app/node_modules/parse-server/lib/PromiseRouter.js:143:13)\n    at /app/node_modules/parse-server/lib/batch.js:91:21\n    at Array.map (<anonymous>)\n    at /app/node_modules/parse-server/lib/batch.js:82:40\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)“}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionSupport or code-level question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions