Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure project to run as https in development mode #703

Open
clluiz opened this issue Jan 29, 2024 · 2 comments
Open

How to configure project to run as https in development mode #703

clluiz opened this issue Jan 29, 2024 · 2 comments

Comments

@clluiz
Copy link

clluiz commented Jan 29, 2024

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.

@clluiz clluiz changed the title How to configure project to run as http in development mode How to configure project to run as https in development mode Jan 30, 2024
@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this feature? Remember to add unit tests.

@weixinwu
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants