I'm using NodeJS (v. 17.8.0) and am using express.js to host my project. My goal is to pass something through the URL, take that something in NodeJS, and send it over a TCP connection. I've been able to update the URL over Vanilla JS but am having issues with the node-url module.
Code thats updating the url:
let newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + 'para=' + id;
window.history.pushState({path:newurl},'',newurl);
NodeJS code:
let express = require('express');
let app = express();
let bodyParser = require('body-parser');
let url = require("url");
let net = require('net');
const path = require('path');
app.use(bodyParser.json());
app.use(express.static('public'));
app.listen(3000, function(){
console.log("Server started on port: 3000");
})
app.get('', (req, res) => {
console.log(req.protocol)
console.log(req.hostname)
console.log(req.path)
console.log(req.originalUrl)
console.log(req.subdomains)
})
What would be the best way to achieve that?