将应用程序连接到Heroku上的ParseServer

时间:2016-02-16 10:02:15

标签: swift heroku parse-server

我正在关注这些教程: http://rogerstringer.com/2016/02/04/parse-server-heroku/ https://devcenter.heroku.com/articles/deploying-a-parse-server-to-heroku

我正在尝试将ParseServer部署到Heroku并使用它连接我的应用程序。 部署部分正常,我可以看到这个: “我梦想成为一个网站。”

我不知道在哪里放置clientId和appId。 这些是来自Heroku部分的配置变量:

Heroku config vars

这是ParseServer中的代码,我在github上的代码:

var api = new ParseServer({
    databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
    cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
    appId: process.env.APP_ID || 'reciparia',
    masterKey: process.env.MASTER_KEY || '' //Add your master key here. Keep it secret!
});

AppDelegate中的代码:

   let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
  ParseMutableClientConfiguration.applicationId = "reciparia"
  ParseMutableClientConfiguration.clientKey = "CLIENT_KEY"
  ParseMutableClientConfiguration.server = "https://amazing-parse.herokuapp.com/parse"
})

由于在ParseClientConfiguration上必须有一个clientKey,我应该在ParseServer上有一个。

我应该把它放在哪里?在Heroku UI的Config Vars上,还是ParseServer的index.js?

1 个答案:

答案 0 :(得分:1)

同一clientKey需要位于ParseServer(位于index.js)和AppDelegate.swift(位于客户端)。

我从ParseServer向clientKey添加了index.js。还需要在双方都找到变量appId

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'reciparia',
  masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
  clientKey: process.env.CLIENT_KEY || 'holla'
});

AppDelegate.swift保持不变:

  let parseConfiguration = ParseClientConfiguration(block: {   (ParseMutableClientConfiguration) -> Void in
     ParseMutableClientConfiguration.applicationId = "reciparia"
     ParseMutableClientConfiguration.clientKey = "holla"
     ParseMutableClientConfiguration.server = "https://amazing-parse.herokuapp.com/parse"
  })

我也修改了一些配置变量,因为这里也有相同的CLIENT_KEY和APP_ID。我发现现在修改配置变量和AppDelegate更方便,因为我的凭据现在公开了:)。

configs