remove static serve from backend
This commit is contained in:
parent
f9b89495b5
commit
beb92327a5
1 changed files with 14 additions and 14 deletions
|
@ -1,11 +1,11 @@
|
|||
const http = require('http');
|
||||
const https = require('https');
|
||||
const cors = require('cors');
|
||||
const express = require('express');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const Config = require('./config.js');
|
||||
const http = require("http");
|
||||
const https = require("https");
|
||||
const cors = require("cors");
|
||||
const express = require("express");
|
||||
const cookieParser = require("cookie-parser");
|
||||
const Config = require("./config.js");
|
||||
|
||||
const UserInterface = require('./user.js');
|
||||
const UserInterface = require("./user.js");
|
||||
|
||||
let credentials = {};
|
||||
|
||||
|
@ -27,7 +27,7 @@ app.use(cookieParser());
|
|||
// force https
|
||||
app.use((req, res, next) => {
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
|
@ -35,17 +35,17 @@ app.use((req, res, next) => {
|
|||
});
|
||||
|
||||
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();
|
||||
} else if (Config.config.https && Config.config.secret == 'TEST_SECRET') {
|
||||
console.error('please do not use the testing secret in production.');
|
||||
} else if (Config.config.https && Config.config.secret == "TEST_SECRET") {
|
||||
console.error("please do not use the testing secret in production.");
|
||||
process.exit();
|
||||
}
|
||||
|
||||
app.use('/api/user', UserInterface.router);
|
||||
app.use("/api/user", UserInterface.router);
|
||||
|
||||
// serve static files last
|
||||
app.use(express.static('./static'));
|
||||
// app.use(express.static('./static'));
|
||||
// DISABLED: no longer needs to serve static files
|
||||
// due to frontend being employed in elm
|
||||
|
||||
|
@ -58,5 +58,5 @@ if (Config.config.https) {
|
|||
}
|
||||
console.log(
|
||||
`listening on port ${Config.config.port || 8080}` +
|
||||
` with https ${Config.config.https ? 'enabled' : 'disabled'}`
|
||||
` with https ${Config.config.https ? "enabled" : "disabled"}`
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue