From eda0276d286a7e1c3e5d25cf8f8a8e7a29397877 Mon Sep 17 00:00:00 2001 From: Joao Fidelis Date: Mon, 20 May 2019 16:56:23 -0300 Subject: [PATCH] check for api/catalog calls, dont add base path for them --- CHANGELOG.md | 4 ++++ manifest.json | 7 +++++++ node/handlers/catalog.ts | 4 +++- node/yarn.lock | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ed448d..6aacd82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Check for requests starting with `api/catalog` and don't change base path for them. +- VtexIdclientAutCookie header. + ## [0.0.5] - 2019-04-26 diff --git a/manifest.json b/manifest.json index 3aba40d..52be687 100644 --- a/manifest.json +++ b/manifest.json @@ -25,6 +25,13 @@ "path": "/{{account}}/search/*" } }, + { + "name": "outbound-access", + "attrs": { + "host": "portal.vtexcommercestable.com.br", + "path": "/api/catalog/*" + } + }, { "name": "colossus-write-logs" } diff --git a/node/handlers/catalog.ts b/node/handlers/catalog.ts index e0be619..61ebf14 100644 --- a/node/handlers/catalog.ts +++ b/node/handlers/catalog.ts @@ -14,10 +14,11 @@ export const catalog = async (ctx: Context) => { // The `portal-search` API has an incorrect endpoint /buscaautocomplete on root. const isAutoComplete = (path as string).startsWith('buscaautocomplete') + const isNewCatalog = (path as string).startsWith('api/catalog/') const [host, basePath] = isGoCommerce ? ['api.gocommerce.com', `${account}/search`] - : ['portal.vtexcommercestable.com.br', isAutoComplete ? '' : 'api/catalog_system'] + : ['portal.vtexcommercestable.com.br', isAutoComplete || isNewCatalog ? '' : 'api/catalog_system'] const cookie = segmentToken && {Cookie: `vtex_segment=${segmentToken}`} const params = { @@ -32,6 +33,7 @@ export const catalog = async (ctx: Context) => { 'Authorization': authToken, 'Proxy-Authorization': authToken, 'User-Agent': process.env.VTEX_APP_ID, + VtexIdclientAutCookie: authToken, ... operationId ? {'x-vtex-operation-id': operationId} : null, ...cookie, }, diff --git a/node/yarn.lock b/node/yarn.lock index 5687c2f..932881f 100644 --- a/node/yarn.lock +++ b/node/yarn.lock @@ -3087,7 +3087,7 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" -"stats-lite@github:vtex/node-stats-lite#dist": +stats-lite@vtex/node-stats-lite#dist: version "2.2.0" resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797" dependencies: