Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #196 from NewSpring/wildcard-whitelist
Browse files Browse the repository at this point in the history
add regex for site whitelisting
  • Loading branch information
johnthepink committed Sep 14, 2016
2 parents bc87319 + f7c0416 commit 7e0e2e4
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,12 @@ async function start() {
res.status(200).end();
});

const whitelist = [
"http://localhost:3000",
"http://localhost:9009",
"http://localhost:12392",
"https://alpha-app.newspring.io",
"https://beta-native.newspring.cc",
"https://beta-my.newspring.cc",
"https://pre-my.newspring.cc",
"https://my.newspring.cc",
"https://newspring.cc",
"http://beta.newspring.cc",
"https://newspringfuse.com",
"http://beta.newspringfuse.com",
"https://newspringnetwork.com",
"http://newspring.dev",
"http://newspringfuse.dev",
"http://newspringnetwork.dev",
];
const sites = /^http(s?):\/\/.*.(newspring|newspringfuse|newspringnetwork).(com|cc|io|dev)$/;
const local = /^http(s?):\/\/localhost:\d*$/;

const corsOptions = {
origin: (origin, callback) => {
const originIsWhitelisted = whitelist.indexOf(origin) !== -1;
const originIsWhitelisted = sites.test(origin) || local.test(origin);
callback(null, originIsWhitelisted);
},
credentials: true,
Expand Down

0 comments on commit 7e0e2e4

Please sign in to comment.