server.js 1003 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const express = require('express');
  2. const ParseServer = require('parse-server').ParseServer;
  3. const cors = require('cors');
  4. const app = express();
  5. // 启用 CORS
  6. app.use(cors());
  7. const api = new ParseServer({
  8. databaseURI: 'postgresql://dev:666@113.44.218.121:5432/dev',
  9. appId: 'dev',
  10. masterKey: 'devmk',
  11. masterKeyIps: ['0.0.0.0/0','::/0'],
  12. allowClientClassCreation: true,
  13. allowHeaders: ["*"],
  14. allowOrigin: "*",
  15. // 添加额外的安全配置
  16. serverURL: 'http://113.44.218.121:1337/parse',
  17. publicServerURL: 'http://113.44.218.121:1337/parse',
  18. // 添加用户认证配置
  19. auth: {
  20. enableAnonymousUsers: false,
  21. enablePasswordReset: true,
  22. },
  23. // 添加邮箱验证配置(可选)
  24. verifyUserEmails: false,
  25. });
  26. async function main() {
  27. await api.start();
  28. // Serve the Parse API at /parse URL prefix
  29. app.use('/parse', api.app);
  30. const port = 1337;
  31. app.listen(port, function() {
  32. console.log('parse-server running on port ' + port + '.');
  33. });
  34. }
  35. main();