diff options
| author | Bobby <[email protected]> | 2022-03-21 01:49:17 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-03-21 01:49:17 -0400 |
| commit | 1a55a855b5e448f2d27065e55ff8bf9900544db5 (patch) | |
| tree | a88a2397e0c280d34d79a89e3bbdd98ecee4f11a /server.js | |
| parent | 8e1815ec8611e791f8658475f3466a742e522f30 (diff) | |
| download | luciferreeves.github.io-1a55a855b5e448f2d27065e55ff8bf9900544db5.tar.xz luciferreeves.github.io-1a55a855b5e448f2d27065e55ff8bf9900544db5.zip | |
try2: adding origins to cors
Diffstat (limited to 'server.js')
| -rw-r--r-- | server.js | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -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); }, }) ); |
