2017-06-19 3 views
0

HerongでホストされているParse ServerをmongoDBで使用しています。私はパスワードリセット機能を働かせて苦労しています。私は指示に従って、index.jsに以下のコードを追加しました。このコードを追加すると、アプリが起動するか、メールを送信しようとすると、次のエラーが表示されます。JSON text did not start with array or object and option to allow fragments not set.パーズサーバでパスワードリセットを設定する際にエラーが発生しました

これはサーバがデータを解析できないことを意味していますが、これを修正する方法は完全にわかりません。どんな助けでも大歓迎です!

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

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI; 

if (!databaseUri) { 
    console.log('DATABASE_URI not specified, falling back to localhost.'); 
} 

var api = new ParseServer({ 
    databaseURI: databaseUri || 'MY_DATABASE_URI', 
    cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', 
    appId: process.env.APP_ID || 'MY_APP_ID', 
    masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret! 
    serverURL: process.env.SERVER_URL || 'MY_SERVER_URL', // Don't forget to change to https if needed 

liveQuery: { 
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions 
} 

verifyUserEmails: true, 
//The public URL of your app. 
//This will appear in the link that is used to verify email addresses and reset passwords. 
//Set the mount path as it is in serverURL 
publicServerURL: 'MY_SERVER_URL_FROM_HEROKU', 
// Your apps name. This will appear in the subject and body of the emails that are sent. 
appName: 'MY_APP_NAME', 
// The email adapter 
emailAdapter: { 
    module: 'parse-server-simple-mailgun-adapter', 
    options: { 
     // The address that your emails come from 
     fromAddress: 'MY_MAILGUN_DOMAIN', 
     // Your domain from mailgun.com 
     domain: 'MY_MAILGUN_DOMAIN', 
     // Your API key from mailgun.com 
     apiKey: 'MY_API_KEY_FROM_MAILGUN', 
    } 
} 
}); 

// Client-keys like the javascript key or the .NET key are not necessary with parse-server 
// If you wish you require them, you can set them as options in the initialization above: 
// javascriptKey, restAPIKey, dotNetKey, clientKey 

var app = express(); 

// Serve static assets from the /public folder 
app.use('/public', express.static(path.join(__dirname, '/public'))); 

// Serve the Parse API on the /parse URL prefix 
var mountPath = process.env.PARSE_MOUNT || '/parse'; 
app.use(mountPath, api); 

// Parse Server plays nicely with the rest of your web routes 
app.get('/', function(req, res) { 
    res.status(200).send('I dream of being a website. Please star the parse-server repo on GitHub!'); 
}); 

// There will be a test page available on the /test path of your server url 
// Remove this before launching your app 
app.get('/test', function(req, res) { 
    res.sendFile(path.join(__dirname, '/public/test.html')); 
}); 

var port = process.env.PORT || 1337; 
var httpServer = require('http').createServer(app); 
httpServer.listen(port, function() { 
    console.log('parse-server-example running on port ' + port + '.'); 
}); 

// This will enable the Live Query real-time server 
ParseServer.createLiveQueryServer(httpServer); 
+0

私はこのjsonを{}の中に置く必要があると思いますが、このコードだけがコンテキスト外です。 Pls、あなたはより多くのコードを入れることができますか?例:var api =新しいParseServer ... –

+0

あなたのjsonも検証するためにいくつかのオンラインツールを使うことができます.. –

+0

Thanks @ClaudioCastro。これが私が追加した唯一のコードです。このコードだけをindex.jsファイルに追加すると、アプリの起動時にエラーが発生します。 – m1234

答えて

1

verifyUserEmailsを設定する前に、livequery:{...}の後にコンマがありません。あなたが電子メールのために追加したブロックが適切に字下げされていないため、ほとんど伝えられません。

+0

もちろん。ありがとうございました! – m1234

関連する問題