0 down vote favorite

I've followed the migration guide and setup the Mongodb, NodeJS and Parse server locally on our Linux server. I'm able use the REST API to login to the game and download game-related files that are still hosted by Parse's S3. However it seems like whenever I'm doing a POST or PUT http requests I receive a 404 not found error.

So far I've tried:

  1. Enabling the HTTP interface in /etc/mongod.conf

  2. Checked the post URLs and they look correct. For logging out I'm sending a post request to http:///parse/logout

  3. Handle http method override following this link: https://stackoverflow.com/questions/24019489/node-js-express-4-x-method-override-not-handling-put-request

I'm thinking there might be something wrong with the setup on the server. Did anyone run into similar problem?

Thanks.

Okay I found the solutions.

Logout problem:

Unity's WWW class seems to work only with valid postData. I didn't provide postData when creating a WWW instance since logout only required custom HTTP request headers. It worked after I created a dummy byte array and pass that to the WWW constructor.

WWW www = new WWW(url, null, headers) // return 404

WWW www = new WWW(url, new byte[1], headers) // worked

PUT problem:

My request headers had 'X-HTTP-Method-Override' set to PUT but it had no effect on the server until I modified allowMethodOverride function inside middlewares.js

var allowMethodOverride = function allowMethodOverride(req, res, next) {

  if (req.method === 'POST' && req.body._method) {
    req.originalMethod = req.method;
    req.method = req.body._method;
    delete req.body._method;
  }
  // Also detect these override request header sent by Unity clients
  else if (req.method === 'POST' && req.get('X-HTTP-Method-Override')) {
    req.originalMethod = req.method;
    req.method = req.get('X-HTTP-Method-Override');
  }
  next();
};

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.