Prerequisites:
- A recent version of Node.js (22 or higher)
- A package manager like npm, pnpm or yarn
1
Setup DNS Records
Before we can start with any code, we need to ensure that the application’s domain is pointing to the server.To do this, go to your cloud provider’s dashboard and find the IP address of the machine that will run your application.
Then, from your DNS provider’s dashboard, create an “A” record with the value set to the IP address of the server.
2
Install MagicServer
- npm
- pnpm
- bun
- yarn
3
Replace you usage of `createServer` with `createMagicServer`
server.js
server.listen()
call.
We do this because MagicServer will automatically listen on port 443, which is the port for HTTPS.4
Start the server
Now whenever your application is started, it will be automatically served over HTTPS and stay up to date with certificates without needing any intervention.
Curious about how it works?
It’s not a sleight of hand! Learn the magic behind MagicServer.