aboutsummaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-03-21 04:48:28 -0400
committerBobby <[email protected]>2022-03-21 04:48:28 -0400
commitea6e14059d8904c83f16ef65dc30dfde70ca78d8 (patch)
treec0630591e6f2f90f7bea4c976d5aef2079c16a51 /server.js
parent1a55a855b5e448f2d27065e55ff8bf9900544db5 (diff)
downloadluciferreeves.github.io-ea6e14059d8904c83f16ef65dc30dfde70ca78d8.tar.xz
luciferreeves.github.io-ea6e14059d8904c83f16ef65dc30dfde70ca78d8.zip
force check referer before api request
Diffstat (limited to 'server.js')
-rw-r--r--server.js21
1 files changed, 4 insertions, 17 deletions
diff --git a/server.js b/server.js
index eb79ff0..8c1024e 100644
--- a/server.js
+++ b/server.js
@@ -2,16 +2,12 @@
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
-
// Import the routes
const routes = require("./routes");
// Create the server
const app = express();
-var allowedOrigins = [
- "http://localhost:3000",
- "https://thatcomputerscientist.com",
-];
+
app.use(function (req, res, next) {
if (
req.get("X-Forwarded-Proto") === "http" &&
@@ -32,18 +28,9 @@ app.use(
extended: true,
})
);
-app.use(
- cors({
- origin: function (origin, callback) {
- // Block everything except the allowed origins
- if (allowedOrigins.indexOf(origin) !== -1) {
- callback(null, true);
- } else {
- callback(new Error("Not allowed by CORS"));
- }
- },
- })
-);
+
+app.use(cors());
+
app.use("/static", express.static(__dirname + "/static"));
app.use(express.static(__dirname + "/public"));
app.engine("html", require("ejs").renderFile);