HTTPS ํ๋กํ ์ฝ์ ์ฌ์ฉํ๋ ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ง๋ค๋ ค๋ฉด ์ต์
๊ฐ์ฒด๋ฅผ ์ ๋ฌํด์ผํฉ๋๋ค.
const httpsOptions = {
key: fs.readFileSync('./secrets/private-key.pem'),
cert: fs.readFileSync('./secrets/public-certificate.pem'),
};
const app = await NestFactory.create(ApplicationModule, {
httpsOptions,
});
await app.listen(3000);
const app = await NestFactory.create<NestFastifyApplication>(
ApplicationModule,
new FastifyAdapter({ https: httpsOptions }),
);
Multiple simultaneous servers
๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ธ์คํด์ค๋ฅผ ์์ ํ ์ ์ดํ๋ฉด ๋ค๋ฅธ ํฌํธ์์ ์์ ๋๊ธฐํ๋ ์ฌ๋ฌ ๊ฐ์ ๋์ ์๋ฒ๋ฅผ ๊ฐ๋จํ๊ฒ ์์ฑํ ์ ์์ต๋๋ค.
const httpsOptions = {
key: fs.readFileSync('./secrets/private-key.pem'),
cert: fs.readFileSync('./secrets/public-certificate.pem'),
};
const server = express();
const app = await NestFactory.create(
ApplicationModule,
new ExpressAdapter(server),
);
await app.init();
http.createServer(server).listen(3000);
https.createServer(httpsOptions, server).listen(443);
info ํํธ ExpressAdapter
๋ @nestjs/platform-express
ํจํค์ง์์ ๊ฐ์ ธ์ต๋๋ค.