Allow list for registration
This commit is contained in:
parent
d21631892f
commit
ffdc4932e8
1 changed files with 11 additions and 12 deletions
|
@ -2,6 +2,8 @@ import { createAppRegisterHandler } from "@saleor/app-sdk/handlers/next";
|
|||
|
||||
import { saleorApp } from "../../saleor-app";
|
||||
|
||||
const allowedUrlsPattern = process.env.ALLOWED_DOMAIN_PATTERN;
|
||||
|
||||
/**
|
||||
* Required endpoint, called by Saleor to install app.
|
||||
* It will exchange tokens with app, so saleorApp.apl will contain token
|
||||
|
@ -9,17 +11,14 @@ import { saleorApp } from "../../saleor-app";
|
|||
export default createAppRegisterHandler({
|
||||
apl: saleorApp.apl,
|
||||
allowedSaleorUrls: [
|
||||
/**
|
||||
* You may want your app to work only for certain Saleor instances.
|
||||
*
|
||||
* Your app can work for every Saleor that installs it, but you can
|
||||
* limit it here
|
||||
*
|
||||
* By default, every url is allowed.
|
||||
*
|
||||
* URL should be a full graphQL address, usually starting with https:// and ending with /graphql/
|
||||
*
|
||||
* Alternatively pass a function
|
||||
*/
|
||||
(url) => {
|
||||
if (allowedUrlsPattern) {
|
||||
const regex = new RegExp(allowedUrlsPattern);
|
||||
|
||||
return regex.test(url);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue