大佬教程收集整理的这篇文章主要介绍了node.js – 如何使用MongoDB在Heroku上托管我自己的解析服务器?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
"dependencies": { "express": "~4.2.x","kerberos": "~0.0.x","parse": "~1.6.12","parse-server": "~2.0",// <= don't forget this comma "cors": "*" // add this line }@H_673_5@注意 @H_673_5@请确保在实际代码中删除上述注释,因为它不是有效的JSON @H_673_5@>打开index.js并进行以下更改: @H_673_5@。 @H_673_5@
var express = require('express'); // find this line in the file var cors = require('cors') // add this line below it //.... //var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI // old name,you may need to change this for new deployments var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI // changed to MONGODB_URI in Heroku! //.... var app = express(); // find this line in the file app.use(cors()); // add this line below it //Add declarations for any keys you plan to use as shown below 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 || 'myAppId',masterKey: process.env.MASTER_KEY || '',serverURL: process.env.SERVER_URL || 'http://localhost:1337',javascriptKey: process.env.JAVASCRIPT_KEY || '',//** add this line no need to set values,they will be overwritten by heroku config vars restAPIKey: process.env.REST_API_KEY || '',//** add this line dotNetKey: process.env.DOT_NET_KEY || '',//** add this line clientKey: process.env.CLIENT_KEY || '',//** add this line });@H_673_5@>回到终端窗口,确保你仍然在我们克隆的repo的文件夹,并输入以下推送更改Heroku: @H_673_5@。 @H_673_5@
$ git add . $ git commit -am "make it better" $ git push heroku master@H_673_5@测试新的Parse服务器 @H_673_5@>转到这个jsFiddle page
Parse.initialize('<MY_APP_ID>','<MY_JS_KEY>'); Parse.serverURL = 'https://<MY_HEROKU_APP_NAME>.herokuapp.com/Parse'@H_673_5@>您应该得到以下警报,让您知道您的新的Parse服务器正常工作 @H_673_5@ @H_673_5@注意: @H_673_5@如果您对多个解析服务器实例使用jsfiddle工具,您可能会收到错误“无效会话令牌”。如果发生这种情况,打开开发控制台,并删除所有的“解析”键从本地存储,之后,它应该工作: @H_673_5@ @H_673_5@从Parse迁移现有数据 @H_673_5@在迁移生产应用程序之前,应至少使用一个测试应用程序执行此操作。此外,似乎旧的应用程序的遗留文件可能还没有传输,见this GitHub Issue @H_673_5@>在我们迁移之前,如果你的新MongoDB有数据,迁移将失败。如果您只是测试服务器并创建和对象,请转到https://dashboard.heroku.com/apps/\u0026lt;MY_HEROKU_APP_NAME\u0026gt;/resources,点击其图标旁边的“MongoLab”,然后在下一页上单击“删除所有集合“
以上是大佬教程为你收集整理的node.js – 如何使用MongoDB在Heroku上托管我自己的解析服务器?全部内容,希望文章能够帮你解决node.js – 如何使用MongoDB在Heroku上托管我自己的解析服务器?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。