Skip to content

Instantly share code, notes, and snippets.

@meditto
Created March 2, 2020 19:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meditto/d2c7ab6d8de3eccb8b5bc6f646d0988a to your computer and use it in GitHub Desktop.
Save meditto/d2c7ab6d8de3eccb8b5bc6f646d0988a to your computer and use it in GitHub Desktop.
use SSL on Adonis 5 dev server
/*
|--------------------------------------------------------------------------
| AdonisJs Server
|--------------------------------------------------------------------------
|
| The contents in this file is meant to bootstrap the AdonisJs application
| and start the HTTP server to accept incoming connections. You must avoid
| making this file dirty and instead make use of `lifecycle hooks` provided
| by AdonisJs service providers for custom code.
|
*/
import 'reflect-metadata';
import sourceMapSupport from 'source-map-support';
import { Ignitor } from '@adonisjs/core/build/src/Ignitor';
import https from 'https';
import path from 'path';
import fs from 'fs';
const options = {
key: fs.readFileSync(path.join(__dirname, 'path to certificate.key from build folder')),
cert: fs.readFileSync(path.join(__dirname, 'path to certificate.crt from build folder'))
};
sourceMapSupport.install({ handleUncaughtExceptions: false });
new Ignitor(__dirname)
.httpServer()
.start((handler: any) => https.createServer(options, handler))
.catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment