From ed4ce0c79250412bd90697556b702e9f322b7c1b Mon Sep 17 00:00:00 2001 From: David Featherston Date: Mon, 3 Oct 2022 09:42:52 +1100 Subject: [PATCH] feat(ripple-nuxt-tide): forward sitemap query params (#1244) Co-authored-by: David Featherston Co-authored-by: Jason Smith --- .../ripple-nuxt-tide/modules/site/module.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/ripple-nuxt-tide/modules/site/module.js b/packages/ripple-nuxt-tide/modules/site/module.js index ff32b1c4a..b79a98d7d 100644 --- a/packages/ripple-nuxt-tide/modules/site/module.js +++ b/packages/ripple-nuxt-tide/modules/site/module.js @@ -10,11 +10,25 @@ module.exports = function () { options: options }) + const getQuery = (req) => { + return req.query ? '&' + new URLSearchParams(req.query).toString() : '' + } + // This won't override nuxt tide module's proxy option, as they have been added into array already. // But this may impact nuxt proxy settings if there is, so need to be reviewed for that case. this.options.proxy = { ...this.options.proxy, - '/sitemap.xml': baseUrl + 'sitemap.xml?site=' + options.site, - '/sitemaps/**/sitemap.xml': { target: baseUrl, pathRewrite: (path) => { return baseUrl + path + '?site=' + options.site } } + '/sitemap.xml': { + target: baseUrl, + pathRewrite: (path, req) => { + return baseUrl + 'sitemap.xml?site=' + options.site + getQuery(req) + } + }, + '/sitemaps/**/sitemap.xml': { + target: baseUrl, + pathRewrite: (path, req) => { + return baseUrl + path + '?site=' + options.site + getQuery(req) + } + } } }