server.js 825 B

1234567891011121314151617181920212223242526272829303132333435
  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. async function main() {
  20. await api.start();
  21. // Serve the Parse API at /parse URL prefix
  22. app.use('/parse', api.app);
  23. const port = 1337;
  24. app.listen(port, function() {
  25. console.log('parse-server running on port ' + port + '.');
  26. });
  27. }
  28. main();