reactjs - 错误提示:- 空闲,状态从启动变为启动,使用 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 logs --tail”后,出现以下错误:
"
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
}
}
});
推荐阅读
- python-3.x - 在python中撤消“导入数学”?
- php - PHP - MySQL 查询不完全工作
- ruby - 构建新的 Jekyll 站点时出错
- html - 如何使 Web 部件页面内的 HTML 内容可搜索?
- c# - 如何检查特定父元素的子元素的值?
- go - Go ReadString 问题:文件名、目录名或卷标语法不正确
- pandas - pandas 数据帧上的自定义 word2vec Transformer 并在 FeatureUnion 中使用它
- proxy - 在 oracle 服务总线中使用 MQ 传输时未创建代理服务
- apache-poi - Apache POI XWPFRun 无法获取 EMF 图片
- python - 使用公共键列 pandas 查找任意两列数据帧之间的差异