aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-03-21 01:49:17 -0400
committerBobby <[email protected]>2022-03-21 01:49:17 -0400
commit1a55a855b5e448f2d27065e55ff8bf9900544db5 (patch)
treea88a2397e0c280d34d79a89e3bbdd98ecee4f11a
parent8e1815ec8611e791f8658475f3466a742e522f30 (diff)
downloadluciferreeves.github.io-1a55a855b5e448f2d27065e55ff8bf9900544db5.tar.xz
luciferreeves.github.io-1a55a855b5e448f2d27065e55ff8bf9900544db5.zip
try2: adding origins to cors
-rw-r--r--server.js14
1 files changed, 5 insertions, 9 deletions
diff --git a/server.js b/server.js
index c0d7212..eb79ff0 100644
--- a/server.js
+++ b/server.js
@@ -35,16 +35,12 @@ app.use(
app.use(
cors({
origin: function (origin, callback) {
- // allow requests with no origin
- // (like mobile apps or curl requests)
- if (!origin) return callback(null, true);
- if (allowedOrigins.indexOf(origin) === -1) {
- var msg =
- "The CORS policy for this site does not " +
- "allow access from the specified Origin.";
- return callback(new Error(msg), false);
+ // Block everything except the allowed origins
+ if (allowedOrigins.indexOf(origin) !== -1) {
+ callback(null, true);
+ } else {
+ callback(new Error("Not allowed by CORS"));
}
- return callback(null, true);
},
})
);