remove static serve from backend

This commit is contained in:
jane 2021-06-14 18:21:40 -04:00
parent f9b89495b5
commit beb92327a5

View file

@ -1,11 +1,11 @@
const http = require('http'); const http = require("http");
const https = require('https'); const https = require("https");
const cors = require('cors'); const cors = require("cors");
const express = require('express'); const express = require("express");
const cookieParser = require('cookie-parser'); const cookieParser = require("cookie-parser");
const Config = require('./config.js'); const Config = require("./config.js");
const UserInterface = require('./user.js'); const UserInterface = require("./user.js");
let credentials = {}; let credentials = {};
@ -27,7 +27,7 @@ app.use(cookieParser());
// force https // force https
app.use((req, res, next) => { app.use((req, res, next) => {
if (Config.config.https) { if (Config.config.https) {
if (req.headers['x-forwarded-proto'] !== 'https') { if (req.headers["x-forwarded-proto"] !== "https") {
return res.redirect(`https://${req.headers.host}${req.url}`); return res.redirect(`https://${req.headers.host}${req.url}`);
} }
} }
@ -35,17 +35,17 @@ app.use((req, res, next) => {
}); });
if (!Config.config.secret) { if (!Config.config.secret) {
console.error('No password secret found. please set `secret` in config.json'); console.error("No password secret found. please set `secret` in config.json");
process.exit(); process.exit();
} else if (Config.config.https && Config.config.secret == 'TEST_SECRET') { } else if (Config.config.https && Config.config.secret == "TEST_SECRET") {
console.error('please do not use the testing secret in production.'); console.error("please do not use the testing secret in production.");
process.exit(); process.exit();
} }
app.use('/api/user', UserInterface.router); app.use("/api/user", UserInterface.router);
// serve static files last // serve static files last
app.use(express.static('./static')); // app.use(express.static('./static'));
// DISABLED: no longer needs to serve static files // DISABLED: no longer needs to serve static files
// due to frontend being employed in elm // due to frontend being employed in elm
@ -58,5 +58,5 @@ if (Config.config.https) {
} }
console.log( console.log(
`listening on port ${Config.config.port || 8080}` + `listening on port ${Config.config.port || 8080}` +
` with https ${Config.config.https ? 'enabled' : 'disabled'}` ` with https ${Config.config.https ? "enabled" : "disabled"}`
); );