错误提示:-Idling,状态从up变为starting,停止所有带有SIGTERM的进程,进程退出,状态为143



我正在尝试注册,但我的数据库似乎没有连接到后端

这是我在服务器文件中写的以下代码:-

import express from 'express';
import bcrypt from 'bcrypt-nodejs';
import cors from 'cors';
import knex from 'knex'; 
import register from './controllers/register.js';
import signin from './controllers/signin.js';
import profile from './controllers/profile.js';
import image from './controllers/image.js';
const db = knex({
client: 'pg',
connection: {
connectionString: process.env.DATABASE_URL,
ssl: true,
}
});

const app = express();
app.use(express.json());
app.use(cors());
app.get('/', (req, res)=> { res.send(`it is workinggggg broooo!`)})
app.post('/signin', (req, res) => { signin(req, res, db, bcrypt) })
app.post('/register', (req, res) => { register(req, res, db, bcrypt) })
app.get('/profile/:id', (req, res) => { profile(req, res, db) })
app.put('/image', (req, res) => { image.handleImage(req, res, db)})
app.post('/imageurl', (req, res) => { image.handleApiCall(req, res)})

app.listen( process.env.PORT || 3000 , ()=> {
console.log(`app is running on port  ${process.env.PORT}`);
});

在运行";heroku日志-尾部;在我的服务器中,我得到以下错误:


"
2020-06-20T21:57:19.000000+00:00 app[api]: Build succeeded
2020-06-20T21:57:20.041241+00:00 heroku[web.1]: Restarting
2020-06-20T21:57:20.057729+00:00 heroku[web.1]: State changed from up to starting
2020-06-20T21:57:21.325688+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-20T21:57:21.423767+00:00 heroku[web.1]: Process exited with status 143
2020-06-20T21:57:22.448784+00:00 heroku[web.1]: Starting process with command `npm start`
2020-06-20T21:57:24.710984+00:00 app[web.1]:
2020-06-20T21:57:24.711011+00:00 app[web.1]: > backend@1.0.0 start /app
2020-06-20T21:57:24.711012+00:00 app[web.1]: > node server.js
2020-06-20T21:57:24.711012+00:00 app[web.1]:
2020-06-20T21:57:25.233826+00:00 app[web.1]: App is running on port 18490
2020-06-20T21:57:25.558723+00:00 heroku[web.1]: State changed from starting to up
2020-06-20T22:01:56.641042+00:00 heroku[router]: at=info method=OPTIONS path="/register" host=ztmsmartbrainapi.herokuapp.com request_id=a113ac16-2729-461a-bc55-fe4780bd1a06 fwd="170.80.70.144" dyno=web.1 connect=0ms service=7ms status=204 bytes=301 protocol=https
2020-06-20T22:01:57.069295+00:00 heroku[router]: at=info method=POST path="/register" host=ztmsmartbrainapi.herokuapp.com request_id=64d15e45-8478-4809-b433-fb2a73f66c55 fwd="170.80.70.144" dyno=web.1 connect=0ms service=292ms status=400 bytes=268 protocol=https
2020-06-20T22:02:58.588010+00:00 heroku[router]: at=info method=GET path="/" host=ztmsmartbrainapi.herokuapp.com request_id=e1a0e6b8-56d6-43b3-bb68-3aa512630094 fwd="170.80.70.144" dyno=web.1 connect=1ms service=4ms status=304 bytes=181 protocol=https
2020-06-20T22:07:23.105112+00:00 heroku[router]: at=info method=GET path="/" host=ztmsmartbrainapi.herokuapp.com request_id=31e8f076-ba82-4854-8b64-45246ba5852b fwd="170.80.70.144" dyno=web.1 connect=1ms service=3ms status=304 bytes=181 protocol=https
2020-06-20T22:07:46.020501+00:00 heroku[router]: at=info method=OPTIONS path="/register" host=ztmsmartbrainapi.herokuapp.com request_id=4253b32c-7c34-4529-92f7-047a0be69304 fwd="170.80.70.144" dyno=web.1 connect=1ms service=3ms status=204 bytes=301 protocol=https
2020-06-20T22:07:46.612772+00:00 heroku[router]: at=info method=POST path="/register" host=ztmsmartbrainapi.herokuapp.com request_id=dbc96cea-62f7-4e2f-9515-dc0addf3a9ac fwd="170.80.70.144" dyno=web.1 connect=1ms service=447ms status=400 bytes=268 protocol=https

它在网络中显示的错误是

{"code":"DEPTH_ZERO_SELF_SIGNED_CERT"}

这个错误已经折磨了我好几天了,我找不到任何准确的解决方案,所以我决定发布它。

我很想从评论中的人那里知道以下错误的原因。

尽管这个问题的解决方案是从服务器js文件中更改它

const db = knex({
client: 'pg',
connection: {
connectionString: process.env.DATABASE_URL,
ssl: true,
}
});

到这个

const db = knex({
client: 'pg',
connection: {
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false

}
}
});

最新更新