How to configure project to run as https in development mode
HI. I've created a fastify project using fastify-cli but I can't find how to make my local project use https. I already generated the certificates.
When not using fastify-cli I can do this:
const fastify = require("fastify")({
https: {
key: fs.readFileSync("path/to/key.pem"),
cert: fs.readFileSync("path/to/cert.pem"),
},
});
But I don't see how to do same when using fastify-cli.
Thanks for reporting! Would you like to send a Pull Request to address this feature? Remember to add unit tests.
I don't think code changes are needed. You can specify the key and cert as such
const options = {
https: {
key: fs.readFileSync("./key.pem"),
cert: fs.readFileSync("./cert.pem"),
},
};
in your app.js file generated by the fastify-cli generate command.
When you run the fastify start command, pass --options or -o to let fastify uses the above options.
Let me know if this solves your questions.