OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Point Sub-domain to Node.js Server

  • Thread starter Thread starter BleuSyn
  • Start date Start date
B

BleuSyn

Guest
I'm having some trouble getting my Node.js server to show up on my sub-domain. Here's what I've done so far:

I have a Windows VPS running a Node.js server at http://192.168.0.12:443/. I want this server to be accessible at https://radio.example.net/. To achieve this, I've pointed an A record for radio.example.net to 192.168.0.12. Despite setting up the A record, the sub-domain still doesn't seem to connect to my Node.js server. Can someone please help me figure out what I might be doing wrong? Specifically, how do I correctly point the sub-domain to my Node.js server running on Windows? I also opened the ports already, and it is accessible at the IP address but not the domain.

Any advice or guidance would be greatly appreciated!

Thanks in advance.

I have tried pointing an A record to the IP address, and I have also opened the ports. I'm using Cloudflare for domain hosting if that matters.

Code:
const express = require('express');
const http = require('http');
const socketIo = require('socket.io');

const app = express();
const server = http.createServer(app);
const io = socketIo(server);

app.use((req, res, next) => {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
    res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    res.setHeader('Access-Control-Allow-Credentials', 'true');
    next();
});

app.use(express.static('public'));


server.listen(443, () => {
    console.log('Server listening on port 443');
});

<p>I'm having some trouble getting my Node.js server to show up on my sub-domain. Here's what I've done so far:</p>
<p>I have a Windows VPS running a Node.js server at <a href="http://192.168.0.12:443/" rel="nofollow noreferrer">http://192.168.0.12:443/</a>.
I want this server to be accessible at <a href="https://radio.example.net/" rel="nofollow noreferrer">https://radio.example.net/</a>.
To achieve this, I've pointed an A record for radio.example.net to 192.168.0.12.
Despite setting up the A record, the sub-domain still doesn't seem to connect to my Node.js server. Can someone please help me figure out what I might be doing wrong? Specifically, how do I correctly point the sub-domain to my Node.js server running on Windows? I also opened the ports already, and it is accessible at the IP address but not the domain.</p>
<p>Any advice or guidance would be greatly appreciated!</p>
<p>Thanks in advance.</p>
<p>I have tried pointing an A record to the IP address, and I have also opened the ports. I'm using Cloudflare for domain hosting if that matters.</p>
<pre><code>const express = require('express');
const http = require('http');
const socketIo = require('socket.io');

const app = express();
const server = http.createServer(app);
const io = socketIo(server);

app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.setHeader('Access-Control-Allow-Credentials', 'true');
next();
});

app.use(express.static('public'));


server.listen(443, () => {
console.log('Server listening on port 443');
});
</code></pre>
 
Top