본문 바로가기

카테고리 없음

[NEXTJS]cert로 https설정하기

참고:https://www.freecodecamp.org/news/how-to-set-up-https-locally-with-create-react-app/

 

 

How to Setup HTTPS Locally with create-react-app

Running HTTPS in development is helpful when you need to consume an API that is also serving requests via HTTPS. In this article, we will be setting up HTTPS in development for our create-react-app with our own SSL certificate. This guide is for macOS user

www.freecodecamp.org

import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as fs from 'fs';

async function bootstrap() {
  const httpsOptions = {
    key: fs.readFileSync('./.cert/key.pem'),
    cert: fs.readFileSync('./.cert/cert.pem') 
  }
  const app = await NestFactory.create(AppModule
    , {httpsOptions} 
    );
  app.useGlobalPipes(new ValidationPipe({skipMissingProperties: true}))
  // await app.listen(3000);
  await app.listen(443);  //https
  // await app.listen(80); //http
}
bootstrap();