简体   繁体   English

解析JS SDK登录到在Node.JS中运行的解析服务器=失败

[英]Parse JS SDK Login into Parse Server running in Node.JS = fail

fellow developers. 开发人员。

I'm migrating an app that was using Parse Hosted and the new code will run inside Node.JS (with express) . 我正在迁移使用Parse Hosted的应用程序,新代码将在Node.JS(带有express)中运行 I am having a bit of a hard time figuring out a problem, though: my JavaScript SDK requests always return "Cannot GET /parse/1/login" , as if I was requesting an invalid express route. 不过,我在解决问题上有些困难: 我的JavaScript SDK请求始终返回“ Cannot GET / parse / 1 / login” ,就好像我在请求无效的快速路线一样。 I know it is valid because if I reproduce the call without the right appID it will return the {"error":"unauthorized"} message. 我知道这是有效的,因为如果我在没有正确的appID的情况下重现呼叫,它将返回{"error":"unauthorized"}消息。

I'm trying the most basic possible version , using Node.JS code from the Parse docs : 我正在尝试使用最基本的版本 ,使用来自Parse文档的 Node.JS代码:

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();

var api = new ParseServer({
  databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database
  cloud: '/home/myApp/cloud/main.js', // Absolute path to your Cloud Code
  appId: 'myAppId',
  masterKey: 'myMasterKey', // Keep this key secret!
  fileKey: 'optionalFileKey',
  serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed
});

// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

app.listen(1337, function() {
  console.log('parse-server-example running on port 1337.');
});

The Node.JS server runs OK and I can even query data using cURL requests with no problems at all. Node.JS服务器运行正常, 我什可以使用cURL请求查询数据 ,而没有任何问题。

My login code is also the most basic possible version, running directly into the browser console in a page that loads the JS SDK: 我的登录代码也是最基本的版本,直接在加载JS SDK的页面中运行到浏览器控制台中:

Parse.User.logIn("user", "pass", {
  success: function(user) {
    console.log('ok', user);
  },
  error: function(user, error) {
    console.log('error', user, error);
  }
});

The return is simply Cannot GET /parse/1/login (it seems to come from Express, but the message changes if I remove the appID , so I know the Parse Server is getting it). 返回的就是Cannot GET /parse/1/login (它似乎来自Express,但是如果我删除appID则消息会更改 ,因此我知道Parse Server正在获取它)。 It is worth noting that this very same call worked perfectly if I issue it against api.parse.com servers: {"code":101,"error":"invalid login parameters"} 值得注意的是,如果我针对api.parse.com服务器发出此调用,则该调用非常有效{"code":101,"error":"invalid login parameters"}

Any ideas? 有任何想法吗?

Sorry, guys, I just found out that the problem was the JS SDK Version . 抱歉,伙计们,我刚刚发现问题在JS SDK版本 Really begginer's mistake, but I just couldn't imagine that it would require changes in the SDK since the new Parse Server should be compatible with the Hosted version. 确实是初学者的错误,但是我无法想象它需要在SDK中进行更改,因为新的Parse Server应该与托管版本兼容。

For the record, I was at JS SDK version 1.6.7 and I updated to the 1.6.14 and it works just fine now. 作为记录, 我使用的是JS SDK版本1.6.7 ,我更新到1.6.14 ,现在可以正常工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM