Learn why custom domains need DNS, connect them to your Lovable project, and follow best practices for seamless configuration.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Understanding Custom Domains and DNS
The Need for Configuration Steps in Lovable
What the Configuration Files Mean
// DNS records sample for custom domain
example.com. IN A 192.0.2.1
www.example.com. IN CNAME example.com.
customDomain: "example.com"
target: "application.lovable.com"
Creating the Custom Domain Configuration File
lovable.config.js
. This file will tell your project which custom domain to use.lovable.config.js
. This snippet sets a property with your custom domain name. Replace www.yourcustomdomain.com
with your actual domain.
module.exports = {
customDomain: "www.yourcustomdomain.com"
};
Updating Your HTML to Reflect the Custom Domain
index.html
or similar landing page, open that file in the Lovable code editor.<head>
tag and add a comment to remind yourself or other collaborators that this project is now linked to the custom domain. For example:
<head>
<meta charset="UTF-8">
<title>My Lovable Project</title>
<!-- Custom domain configured in lovable.config.js -->
</head>
Configuring Your Domain Registrar's DNS Records
www
) points to the default Lovable project domain provided by the platform. Your Lovable project setup page should list the target domain (for example, your-project.lovableapp.com
).www
) to work, follow your domain provider’s guidelines. Often, this requires an A record pointing to an IP address that Lovable shares, or a URL redirection to the www
version.
SSL Certificate Management (Handled Automatically)
Testing Your Custom Domain
www.yourcustomdomain.com
). You should see your Lovable project live and secured with HTTPS.
Understanding Custom Domain Requirements
Creating the Domain Configuration File in Lovable
domain.config.json
. This file will store your custom domain settings.domain.config.json
. This configuration file tells your application which domain to use and where to find your SSL certificate and private key:
{
"customDomain": "www.example.com",
"ssl": {
"certificate": "path/to/your/certificate.pem",
"privateKey": "path/to/your/privatekey.pem"
}
}
Integrating the Domain Configuration into Your Application Code
app.js
or server.js
, in the Lovable editor.
const fs = require('fs');
const domainConfig = JSON.parse(fs.readFileSync('./domain.config.json', 'utf8'));
// Middleware to process requests from the custom domain
function customDomainMiddleware(req, res, next) {
if (req.hostname === domainConfig.customDomain) {
// Place any additional custom domain processing logic here
return next();
}
return next();
}
app.use(customDomainMiddleware);
Adding SSL Support for Custom Domains
const https = require('https');
const sslOptions = {
key: fs.readFileSync(domainConfig.ssl.privateKey),
cert: fs.readFileSync(domainConfig.ssl.certificate)
};
https.createServer(sslOptions, app).listen(443, () => {
console.log('HTTPS server running on port 443');
});
Troubleshooting and Best Practices
domain.config.json
for any syntax errors such as missing commas or incorrect paths.When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.