From 5043669d05a16c532ce6dfe0fe71c597dd03b9b0 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 15 Aug 2022 18:56:38 +0200 Subject: [PATCH] DEV: Proxy `mobile_view` param to /bootstrap.json (#17934) Without this it took an extra request for the setting to take in dev mode. Also, append `preview_theme_id` only when present. --- .../javascripts/discourse/lib/bootstrap-json/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js index 3f5a8072b01..50ebf5daa97 100644 --- a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js +++ b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js @@ -241,13 +241,21 @@ async function buildFromBootstrap(proxy, baseURL, req, response, preload) { const forUrlSearchParams = new URL(req.url, "https://dummy-origin.invalid") .searchParams; + + const mobileView = forUrlSearchParams.get("mobile_view"); + if (mobileView) { + url.searchParams.append("mobile_view", mobileView); + } + const reqUrlSafeMode = forUrlSearchParams.get("safe_mode"); if (reqUrlSafeMode) { url.searchParams.append("safe_mode", reqUrlSafeMode); } const reqUrlPreviewThemeId = forUrlSearchParams.get("preview_theme_id"); - url.searchParams.append("preview_theme_id", reqUrlPreviewThemeId); + if (reqUrlPreviewThemeId) { + url.searchParams.append("preview_theme_id", reqUrlPreviewThemeId); + } const res = await fetch(url, { headers: req.headers }); const json = await res.json();