我创建了一个环回API并将其部署在now.sh上。 部署后,我可以浏览目录,但不能调用API URL。我的项目结构如下:
Package.json文件:
{
"name": "****",
"version": "1.0.0",
"main": "server/server.js",
"engines": {
"node": ">=6"
},
"now":{
"name":"****",
"alias":["****"],
"env":{
"MONGODB_URL":"@lbmongonew",
"NODE_ENV":"production"
}
},
"scripts": {
"lint": "eslint .",
"now:deploy":"now",
"now:alias":"now alias",
"now":"npm run now:deploy && npm run now:alias",
"posttest": "npm run lint && nsp check",
"start": "node ."
},
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"helmet": "^3.10.0",
"loopback": "^3.22.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^6.2.0",
"loopback-connector-mongodb": "^4.0.0",
"now": "^13.1.2",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^3.0.0",
"todo": "^1.1.0"
},
"devDependencies": {
"eslint": "^3.17.1",
"eslint-config-loopback": "^8.0.0"
},
"repository": {
"type": "",
"url": ""
},
"license": "UNLICENSED",
"description": "****"}
我的config.production.json文件如下:
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3000,
"remoting": {
"context": false,
"rest": {
"handleErrors": false,
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false
}}
注意:我没有更改主机和端口,因为主机是用于部署的动态主机,并且现在在不断更改每个部署。sh
这是部署后我可以浏览的目录
当我浏览“ https://URL/explorer”时,出现“找不到页面”错误。 浏览API时我在这里缺少什么?
答案 0 :(得分:0)
您是否正在使用现在v2 ?如果是这样,则在部署之前,您需要在now.json
或package.json
中使用Node Builder。
https://zeit.co/docs/v2/deployments/official-builders/node-js-now-node/