Custom Domain for API

I’ve been trying to figure out a way to create an API with my custom domain that I bought for my game with express, but everything I’ve tried so far hasn’t been successful. I know HTML and Node.js, but am not very experienced with web development.

I want to put the site on my Digital Ocean server. I already know how to upload code and everything to the server and how to use express, and have my code for it already, but I don’t know how to set it up with my custom domain and make it usable instead of just having localhost://port.

If you are using a VPS, log into your DNS settings and make an A record for the IP of your server.

Thanks for replying. I had made an A record for the IP of the server already, but I’m just not sure how to utilize it in my code.

Can you explain this ^^^

To change it from http://localhost:port to my custom domain.

What happens when you visit your custom domain? If you custom domain works, just change localhost to your domain and the port to 80 (http) or 443 (https).

All I’m seeing is this. I don’t know why it says Namecheap though. I transferred it to Cloudflare.

Hmm, could still be propagating. How long ago was that?

30 minutes or so.

It might still need more time. Cloudflare will send you an email once the domain has transferred.

1 Like


1 Like

I got the email almost directly after I changed the nameservers and didn’t notice. I’m still seeing the namecheap registration page on my domain though. These are the only DNS records besides the one pointing to my server’s IP address.

You should delete all of those records. I think the CNAME one is messing everything up.

That fixed it. I’m seeing this now though.

I’m using this as a placeholder for now and then I’ll upload the code I put on glitch once I ensure everything’s working fine.

const express = require("express");
const app = express();


const listener = app.listen(443, () => {
    console.log("app running")

app.get("/", (req, res) => {

I uploaded it to my server, but don’t know what to do next.

Is that image the error you got?

It’s what it shows when I visit the site.

Odd, could you show me your A record? You can also PM it to me. redirects to for me

Yeah. Same. I had added nameservers pointing to the ones for Digital Ocean, and now for some reason it’s redirecting to google which is super weird. No clue why.

It has done the same for every other domain I tried adding to Digital Ocean. (all of the DNS records are deleted)