无法启动 Sails.JS 服务器

Cannot start Sails.JS server

我刚刚使用 sails new sails 安装了一个新的 Sails.JS。我已经安装了所有依赖项,并且 node_modules 文件夹可用。但是当我尝试使用 sails lift 运行 服务器时,它给我错误:

error:
error: Error:
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
No `sails.config.sockets.onlyAllowOrigins` or `sails.config.sockets.beforeConnect`
setting was detected.  For security reasons, one of these options must be set
when running Sails in a production environment.
For example (in config/env/production.js):

sockets: {
  onlyAllowOrigins: ["http://www.mydeployedapp.com", "http://mydeployedapp.com"]
}


-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

    at Hook.configure (A:\Projects\sails\node_modules\sails-hook-sockets\lib\configure.js:60:13)
    at Hook.wrapper [as configure] (A:\Projects\sails\node_modules\@sailshq\lodash\lib\index.js:3275:19)
    at A:\Projects\sails\node_modules\sails\lib\app\private\loadHooks.js:331:20
    at A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:3083:16
    at eachOfArrayLike (A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:1003:9)
    at eachOf (A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:1051:5)
    at Object.eachLimit (A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:3145:5)
    at configure (A:\Projects\sails\node_modules\sails\lib\app\private\loadHooks.js:328:17)
    at A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:3853:24
    at replenish (A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:946:17)
    at iterateeCallback (A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:931:17)
    at A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:906:16
    at A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:3858:13
    at A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:421:16
    at iteratorCallback (A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:998:13)
    at A:\Projects\sails\node_modules\sails\node_modules\async\dist\async.js:906:16
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
    at Function.Module.runMain (module.js:695:11)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

error: Could not load Sails app.
error:
error: Tips:
error:  • First, take a look at the error message above.
error:  • Make sure you've installed dependencies with `npm install`.
error:  • Check that this app was built for a compatible version of Sails.
error:  • Have a question or need help?  (http://sailsjs.com/support)

请帮帮我。

如果您没有在应用程序中使用套接字,则打开项目根文件夹中的 .sailsrc 文件并在其中添加 hooks 对象

{
    "generators": {
         "modules": {}
    },
    "hooks" : {
          "sockets" : false
    },
    "_generatedWith": {
           "sails": "1.0.2",
           "sails-generate": "1.15.28"
    }
}

只需在 production.js 文件中输入 'http://localhost'

onlyAllowOrigins: [
  'https://example.com',
  'https://staging.example.com',
  **'http://localhost'**
],