How to make APIs on server secured (HTTPS)

Hello everyone,
I’m new to Cloudflare, and I just secured my domain with CF’s ssl certificate. And it works well!
I still have a problem though, I have a NodeJS application that runs in my server and the certificate I generated doesn’t work well for it.
It still gives me that the API is not secure and I have to go with (Advanced => Proceed to --------- (unsafe)) on Google Chrome and other browsers.
Here’s a peak on my code.

const privateKey = fs.readFileSync("/etc/ssl/private/key.pem", “utf8”); //CF’s SSL key
const certificate = fs.readFileSync("/etc/ssl/certs/cert.pem", “utf8”); //CF’s SSL cert
let credentials = { key: privateKey, cert: certificate };
let httpsServer = https.createServer(credentials, app);
httpsServer.listen(PORT, () => {
console.log(HTTPS started on port ${PORT});
});

My APIs have to be secure too in order to communicate with the Frontend. It should be similar to that : https://0.0.0.0:port/api/request

PS: My server is on DigitalOcean, using Ubuntu as a OS, and NGINX.

Thanks for your help!

Which port?

The following ports are proxied by Cloudflare:

It’s on port 4000

I changed it to 2053 and it’s always not working
When I hit https://myIpAdress:2053/ it’s always not secure.

Thanks!

‘Doesnt work’ doesn’t work here. How should anyone be able to help without any error message.:thinking:
Sharing the domain would be even better.

What’s the error? You wrote ‘myipaddress.com’ and that’s not a Cloudflare issue then. You need a valid certificate on your origin and your Apache or nginx needs to be configured properly.

What’s the SSL setting on your dashboard? Felxible, Full or Full (strict)?

This topic was automatically closed after 31 days. New replies are no longer allowed.