diff options
| author | Bobby <[email protected]> | 2022-03-21 04:48:28 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-03-21 04:48:28 -0400 |
| commit | ea6e14059d8904c83f16ef65dc30dfde70ca78d8 (patch) | |
| tree | c0630591e6f2f90f7bea4c976d5aef2079c16a51 /server.js | |
| parent | 1a55a855b5e448f2d27065e55ff8bf9900544db5 (diff) | |
| download | luciferreeves.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.js | 21 |
1 files changed, 4 insertions, 17 deletions
@@ -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); |
