Allow list for registration

This commit is contained in:
Krzysztof Wolski 2023-03-07 19:59:56 +01:00
parent d21631892f
commit ffdc4932e8

View file

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