From 9974a070bb700112361d5b7d4f5c92795b1faf64 Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Thu, 19 Dec 2019 14:46:08 +1100 Subject: [PATCH] fix: avoid caching of storefront api responses --- server/plugins/router/router.module.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server/plugins/router/router.module.js b/server/plugins/router/router.module.js index ecbed056..2d854ef5 100644 --- a/server/plugins/router/router.module.js +++ b/server/plugins/router/router.module.js @@ -11,6 +11,7 @@ const internals = { renderer: '/{url*}', staticAssets: '/assets/{path*}', internalApi: '/internalapi/{path*}', + storefrontAPI: '/api/storefront/{path*}', cdnAssets: '/stencil/{versionId}/{fileName*}', cssFiles: '/stencil/{versionId}/css/{fileName}.css', favicon: '/favicon.ico', @@ -109,6 +110,25 @@ internals.registerRoutes = function(server, next) { }, }, }, + { + method: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], + path: internals.paths.storefrontAPI, + handler: { + proxy: { + host: internals.options.storeUrl.replace(/http[s]?:\/\//, ''), + rejectUnauthorized: false, + protocol: 'https', + port: 443, + passThrough: true, + xforward: true, + }, + }, + config: { + state: { + failAction: 'log', + }, + }, + }, { method: 'GET', path: internals.paths.favicon,