feat(api): add wildcard fallback host filtering for stage/dev

This commit is contained in:
41666 2021-03-13 15:57:28 -05:00
parent 6edfe7455f
commit 3388e091c1

View file

@ -203,5 +203,13 @@ export const getQuery = (request: Request): { [x: string]: string } => {
};
export const isAllowedCallbackHost = (host: string): boolean => {
return host === apiPublicURI || allowedCallbackHosts.includes(host);
return (
host === apiPublicURI ||
allowedCallbackHosts.includes(host) ||
allowedCallbackHosts
.filter((callbackHost) => callbackHost.includes('*'))
.find((wildcard) =>
new RegExp(wildcard.replace('*', '[a-z0-9-]+')).test(host)
) !== null
);
};