Eli
Eli

Reputation: 51

mkcert HTTPS certificate (with nestjs local server) is working on local machine only

I have nestjs server running locally that I set up to handle HTTPS requests via mkcert. my main.ts file looks like this:

async function bootstrap() {
  const httpsOptions = {
    key: fs.readFileSync('./cert/localhost+1-key.pem'),   
    cert: fs.readFileSync('./cert/localhost+1.pem'),
  };

  const app = await NestFactory.create(AppModule, { cors: true, httpsOptions });

  app.useGlobalPipes(
    new ValidationPipe({
      whitelist: true,
      transformOptions: { enableImplicitConversion: true },
    }),
  );
  
  app.use(json({ limit: '50mb' }));
  app.use(urlencoded({ extended: true, limit: '50mb' }));
  await app.listen(3333);
}
bootstrap();

I have a pwa (react - vite - pwa) app deployed on netlify. If I open the app locally (same machine I have the running server) and send https request to my local nestjs server I get a normal response. However, if I open the same app on a different machine or mobile device, I get (failed)net::ERR_CERT_AUTHORITY_INVALID.

Is there any way to configure nestjs server to receive https requests from any machine/device with mkcert or is it a wrong tool for the task?

Upvotes: 0

Views: 234

Answers (0)

Related Questions