我无法将json服务器中的公用文件夹部署到Heroku

时间:2018-12-28 06:10:29

标签: heroku json-server

我可以正确显示db.json文件,但是如果我放置一个公共文件夹(将我的images文件夹放到public内),heroku仅显示一个空对象。如果我不放置公用文件夹,它将起作用。公用文件夹有什么问题?

server.js

const jsonServer = require('json-server');
const server = jsonServer.create();
const router = jsonServer.router('db.json');
const middlewares = jsonServer.defaults();
const port = process.env.PORT || 4000;

server.use(middlewares);
server.use(router);

server.listen(port);

package.json

{
"name": "json-server-heroku",
"version": "1.0.0",
"description": "Simple json-base database to deploy to Heroku",
"main": "server.js",
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js"
},
"keywords": [
"json-server,heroku, node, REST API"
],
"author": "ABC",
"license": "ISC",
"dependencies": {
"json-server": "^0.12.1"
 }
}

0 个答案:

没有答案