Updating to redirect to correct domain

This commit is contained in:
Glitch (jasonsplant)
2020-05-06 02:20:43 +00:00
parent d0b78e45a7
commit 713909baf1
4 changed files with 38 additions and 23 deletions

View File

@@ -7,6 +7,10 @@ const app = express();
// Handle requests for the root page by serving the static index.html from the views folder
app.get("/", function(req, res) {
if (!req.headers['x-real-host'] && req.headers.host.includes('glitch.me')) {
return res.redirect('https://www.jasonsplant.ml' + req.url);
}
res.sendFile(__dirname + "/views/index.html");
});

View File

@@ -3,7 +3,6 @@ const twit = require('twit')
require('dotenv').config({path: path.join(__dirname, '../../.env')})
const alert = (type) => {
console.log('Alert triggered for type: ' + type)
var tweet = false
switch(type) {

View File

@@ -54,7 +54,7 @@ const Readings = sequelize.define('readings', {
// If the first low reading was more than 4 days ago, send an alert
if (lowtriggered > fourdays) {
// Send alert that water is needed
message('needwater')
message('wantwater')
// Flag that an alert has been sent
Settings.update({ value: new Date().toISOString() }, { where: { key: 'alert' } })