我已经制作了一个API,并且所有路由都可以使用到现在。当我尝试向路由“ /骗子”发出POST请求时,收到以下错误消息:错误:写EPROTO 1979668328:error:100000f7:SSL例程:OPENSSL_internal:WRONG_VERSION_NUMBER:../../ third_party / boringssl / src / ssl / tls_record.cc:242:
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const utils = require('./utils');
const app = express();
const port = process.env.PORT || 4000;
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/db', {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
}).then(db => console.log('DB is connected! '))
.catch(err => console.log(err));
const Users = require('./models/users');
app.use(cors());
app.use(express.json());
const fieldCheck = (field, res) => {
return !field ? (res.status(400).json({
error: true,
message: `Invalid ${field}`
})) : field
}
app.route('/scammer')
.post(async (req, res) => {
const userId = fieldCheck(req.body.user_id, res);
await Users.updateOne({ 'user_id': userId }, { 'scammer': req.body.scammer });
res.json({ 'error': false });
});
app.listen(port, () => {
console.log('Server started on: ' + port);
});
例程:OPENSSL_internal:WRONG_VERSION_NUMBER:../../ third_party / boringssl / src / ssl / tls_record.cc:242:
它表明您使用了HTTPS的HTTPS插入到API
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句