mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
feat: add https support
This commit is contained in:
parent
181f198260
commit
745cd22c16
2 changed files with 16 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -24,3 +24,4 @@ cache
|
|||
.*cache
|
||||
.DS_Store
|
||||
*.env
|
||||
*.pem
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import https from 'https';
|
||||
import fs from 'fs/promises';
|
||||
import Koa from 'koa';
|
||||
import koaLogger from 'koa-logger';
|
||||
|
||||
|
@ -16,6 +18,19 @@ export default async function initApp(app: Koa): Promise<void> {
|
|||
|
||||
app.use(koaUIProxy());
|
||||
|
||||
const { HTTPS_CERT, HTTPS_KEY } = process.env;
|
||||
if (HTTPS_CERT && HTTPS_KEY) {
|
||||
https
|
||||
.createServer(
|
||||
{ cert: await fs.readFile(HTTPS_CERT), key: await fs.readFile(HTTPS_KEY) },
|
||||
app.callback()
|
||||
)
|
||||
.listen(port, () => {
|
||||
console.log(`App is listening on port ${port} with HTTPS`);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`App is listening on port ${port}`);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue