Skip to content

Commit

Permalink
feat: make it possible to exclude routes from being proxied in vtex
Browse files Browse the repository at this point in the history
  • Loading branch information
soutofernando committed Sep 25, 2024
1 parent 180b9f3 commit cfd5d6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions shopify/loaders/ProductListingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ export const cacheKey = (props: Props, req: Request): string | null => {
startCursor,
sort,
});

url.searchParams.forEach((value, key) => {
if(!key.startsWith("filter.")) return;
if (!key.startsWith("filter.")) return;

searchParams.append(key, value);
});
Expand Down
1 change: 0 additions & 1 deletion vtex/loaders/product/extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export interface Props {
* @description Adds brand information to products, useful for Intelligent Search loaders.
*/
brands?: boolean;


products: Product[];
}
Expand Down
13 changes: 12 additions & 1 deletion vtex/loaders/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ const buildProxyRoutes = (
includeSiteMap,
generateDecoSiteMap,
excludePathsFromDecoSiteMap,
excludePathsFromVtexProxy,
includeScriptsToHead,
}: {
publicUrl?: string;
extraPaths: string[];
includeSiteMap?: string[];
generateDecoSiteMap?: boolean;
excludePathsFromDecoSiteMap: string[];
excludePathsFromVtexProxy?: string[];
includeScriptsToHead?: {
includes?: Script[];
};
Expand Down Expand Up @@ -91,7 +93,10 @@ const buildProxyRoutes = (
},
});
};
const routesFromPaths = [...PATHS_TO_PROXY, ...extraPaths].map(
const currentPathsToProxy = PATHS_TO_PROXY.filter((path) =>
!excludePathsFromVtexProxy?.includes(path)
);
const routesFromPaths = [...currentPathsToProxy, ...extraPaths].map(
routeFromPath,
);

Expand Down Expand Up @@ -149,6 +154,10 @@ export interface Props {
* @title Exclude paths from /deco-sitemap.xml
*/
excludePathsFromDecoSiteMap?: string[];
/**
* @title Exclude paths from VTEX PATHS_TO_PROXY
*/
excludePathsFromVtexProxy?: string[];
/**
* @title Scripts to include on Html head
*/
Expand All @@ -166,6 +175,7 @@ function loader(
includeSiteMap = [],
generateDecoSiteMap = true,
excludePathsFromDecoSiteMap = [],
excludePathsFromVtexProxy = [],
includeScriptsToHead = { includes: [] },
}: Props,
_req: Request,
Expand All @@ -174,6 +184,7 @@ function loader(
return buildProxyRoutes({
generateDecoSiteMap,
excludePathsFromDecoSiteMap,
excludePathsFromVtexProxy,
includeSiteMap,
publicUrl: ctx.publicUrl,
extraPaths: extraPathsToProxy,
Expand Down

0 comments on commit cfd5d6c

Please sign in to comment.