/lovable-integrations

Lovable and Let's Encrypt integration: Step-by-Step Guide 2025

Learn how to integrate Lovable with Let's Encrypt to automate SSL installation and boost your site's security. Step-by-step instructions for seamless setup.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to integrate Lovable with Let's Encrypt?

 

Step: Adding Required Dependencies into Your Project

 

Since Lovable doesn’t offer a terminal, you need to add dependency declarations directly into your project’s configuration file. Open your project’s package.json file and add the following dependencies. This tells Lovable to include the automatic Let’s Encrypt certificate management package.


{
  "name": "lovable-project",
  "version": "1.0.0",
  "dependencies": {
    "express": "^4.18.2",
    "greenlock-express": "^4.0.0"
  },
  "scripts": {
    "start": "node dist/main.js"
  }
}

Make sure to save this file in the root directory of your project.

 

Step: Creating the Certificate Manager Module

 

Create a new file named certManager.ts in your source code folder. This module will configure and initialize Let’s Encrypt using the greenlock-express library. Paste the following code into certManager.ts:


// Import the greenlock-express module
import * as GreenlockExpress from 'greenlock-express';

export const createGreenlock = () => {
    return GreenlockExpress.create({
        // Add your email address for renewal notifications
        email: '[email protected]',
        // Agree to the Let's Encrypt Subscriber Agreement
        agreeTos: true,
        // The domains you want the certificate for
        approvedDomains: ['example.com'],
        // Set the config directory for certificates (if applicable)
        configDir: './greenlock.d',
        // Use the staging server for testing. Change to 'https://acme-v02.api.letsencrypt.org/directory' for production.
        server: 'https://acme-staging-v02.api.letsencrypt.org/directory',
        // Whether or not to run in debug mode
        debug: false
    });
};

Replace the email and the approvedDomains with your specific details. This module sets up Greenlock to automatically manage certificate issuance and renewal.

 

Step: Modifying Your Main Server Code to Use Let’s Encrypt

 

Open your main server file (for example, main.ts). Import the Express module and the certificate manager module you just created. Then modify the server startup code so that greenlock-express handles the HTTPS configuration. Insert the following code into your main.ts:


import express from 'express';
import { createGreenlock } from './certManager';

// Create your Express application
const app = express();

// Define your routes and other middleware
app.get('/', (req, res) => {
    res.send('Hello from Lovable with Let's Encrypt!');
});

// Create the Greenlock instance for automatic SSL/TLS handling
const greenlock = createGreenlock();

// Start the HTTPS server using Greenlock
greenlock.listen(80, 443, function () {
    console.log("Listening for ACME challenges on ports 80 and 443...");
});

This code sets up an Express server and then uses the greenlock-express instance to listen on both HTTP (port 80) and HTTPS (port 443). Greenlock will automatically handle obtaining and renewing certificates from Let’s Encrypt.

 

Step: Finalizing Your Project Setup

 

After adding the above files, ensure your project’s build process (if you have one) compiles your TypeScript code into JavaScript. Verify that your tsconfig.json is correctly configured to compile files from your source directory (usually src) into a designated output directory (for example, dist).

For example, a basic tsconfig.json might look like this:


{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "outDir": "./dist",
    "strict": true,
    "esModuleInterop": true
  },
  "include": ["./*/.ts"],
  "exclude": ["node_modules"]
}

Lovable will use the built files to run your project. If your project does not perform TypeScript compilation automatically, make sure to include a build step in your project settings or configure Lovable to use the provided package.json start script.

 

Usage and Testing

 

Once all the above changes are in place, save every file and instruct Lovable to run your project (using the provided start script in package.json). Greenlock-express will then manage the ACME HTTP challenge on port 80 and serve HTTPS traffic on port 443 using Let’s Encrypt certificates.

Visit your domain (for example, https://example.com) to verify that your project is running with valid SSL/TLS certificates from Let’s Encrypt.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022