From a21700a444bd6f39d1b9b3104df3dd6f4e13a4b1 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 17 May 2021 14:51:36 -0400 Subject: [PATCH] FIX: Previewing themes didn't work in Ember CLI (#13078) This is two fixes: 1. Ember CLI's proxy did not support 3xx redirects so a redirect was failing. 2. We were not passing query parameters to the `bootstrap.json` endpoint to correctly handle previewing themes (and other occasional options.) --- .../javascripts/discourse/lib/bootstrap-json/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js index 3b97c65d419..f8dc77a277d 100644 --- a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js +++ b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js @@ -162,7 +162,13 @@ function buildFromBootstrap(assetPath, proxy, baseURL, req, headers) { path.join(process.cwd(), "dist", assetPath), "utf8", (err, template) => { - getJSON(`${proxy}${baseURL}bootstrap.json`, null, req.headers) + let url = `${proxy}${baseURL}bootstrap.json`; + let queryLoc = req.url.indexOf("?"); + if (queryLoc !== -1) { + url += req.url.substr(queryLoc); + } + + getJSON(url, null, req.headers) .then((json) => { resolve(applyBootstrap(json.bootstrap, template, headers)); }) @@ -194,7 +200,7 @@ async function handleRequest(assetPath, proxy, baseURL, req, res) { } req.headers["X-Discourse-Ember-CLI"] = "true"; - let get = bent("GET", [200, 404, 403, 500]); + let get = bent("GET", [200, 301, 302, 303, 307, 308, 404, 403, 500]); let response = await get(url, null, req.headers); res.set(response.headers); if (response.headers["x-discourse-bootstrap-required"] === "true") {