typescript - https.createServer 不工作 REST 服务器
问题描述
我正在尝试使用 express 和 typescript 创建一个 HTTPS 服务器,这是我的代码,由于某种原因 https.createserver 似乎永远无法正常工作,我收到此错误:
UnhandledPromiseRejectionWarning: Error: error:0909006C:PEM routines:get_name:no start line
但我是新手,我在网上找到了 0 个答案。
在我的构造函数中的 App.ts 上,我有:
this.express= express();
const key = fs.readFileSync('/home/user/private.key');
const cert = fs.readFileSync('/home/user/file.csr');
this.middlewares();
this.routes();
this.app = https.createServer({ key, cert }, this.express);
以及初始化应用程序的函数监听:
listen() {
this.app.listen(3000);
console.log('Server on port', 3000);
}
在我的 index.ts 上
import { App } from './app'
import { connect } from './database'
function main() {
const app = new App(4001);
app.listen();
}
main();
解决方案
推荐阅读
- xamarin - 如何自定义窗口拍照
- go - 输出标准输入和标准输出 os.exec Golang
- android-studio - Android模拟器扩展控件不更新模拟器
- fp-ts - 替换 fp-ts 中的数组元素
- python - 将for循环值存储到python中的列表中
- swift - 搜索期间未加载搜索 Tableview
- reactjs - 如何在 React 中使用带有 Typescript 的 ContextAPI 传递和设置状态?
- java - 重用从 Server 获取的 HttpConnection 用于 HttpClient
- python - 如何在 PyQt5 中的 QVideoWidget 中旋转视频
- flutter - Dart 客户端类型通用 REST Api 调用