-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
bodyParser.text() renders Parse unable to process requests (outputs "Unauthorized") #4681
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
Your body parser is conflicting with the JSON body parser that parse-server internally use. |
@flovilmart - what solution would you suggest to allow the requests to be parsed by both the Express server as well as Parse-Server? |
@flovilmart - We are also looking for a solution for this, we just need some mechanism to inspect the request before allowing to proceed to parse-server (note: we'd be using this as a workaround for a hook like this: #4524) |
Feel free to open a pull request if you find a solution, but it’s unlikely we’ll look for one given the very narrow use case you’re describing. |
@flovilmart Sounds good! I'm wondering if parse-server could default to using req.body if it exists, so it doesn't try to re-read the stream. I could look into submitting this, but I imagine there might be wide implications to a change like this too. |
As you mention, there may be other implications. I’m not sure we’d want to slow the processing for everyone else just for your case. Also, you could always restore the contents of the body after inspecting it. |
That makes sense, and thanks for the input @flovilmart! I dug into this a little more and realized it's probably more in the scope of the bodyParser module versus parse-server itself and gained some insight here (https://github.com/expressjs/body-parser/issues/207) where it says there's a flag that can be set Lastly, I think I may have diverged a bit from the original author's topic, sorry for not opening a new thread! |
It’s fine, it complements the original concern with a potential way to workaround! |
@Koosmann thanks for digging into this - super helpful, thanks! |
Issue Description
I'm attempting to log request payloads for monitoring reasons and it seems that everytime I use the bodyParser.text() in my express server (I'm logging Parse JS SDK calls, and it appears that only the bodyParser.text places the payload in req.body), the parse-server is not able to use the rest of the request.
When bodyParser.text() is in place, all requests respond with:
ParseError {code: undefined, message: "unauthorized"}
Do you know why this is the case?
Steps to reproduce
On the JS side, I merely use a call with the following code:
Expected Results
I expect the Parse-Server to console log the request payload, and the response to return the Parse Query.
Actual Outcome
Parse-Server logs the request payload, but Parse Query is responded with "unauthorized"
Environment Setup
The text was updated successfully, but these errors were encountered: