I recently purchased a VPS from OVH for the hosting of my discord bot. It has a stats.json page that I need to have another site GET to, but I can't seem to find my VPS's express site.
I'm trying to access it from my vpsXXXXXX.vps.ovh.ca
, but I get the error: This site can’t be reached
. I have the following on my main code:
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.get("/", (request, response) => {
response.sendStatus(200);
});
app.get('/stats', function(request, response) {
response.sendFile(__dirname + "/stats.json");
});
And even with this code, I get no response from the VPS's URL.
I'd want to have my glitch.me
site to be able to GET the data from the stats.json
, but I can't seem to find or figure out a way to get a URL for my VPS.
Does anyone know how to connect a URL or use the VPS URL?
Thank You!
Codingpro
You forgot to listen. Set the environment port instead
var port = process.env.PORT || 3000
app.listen(port, () => console.log(`Online on port ${port}!`))