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.)
This commit is contained in:
Robin Ward 2021-05-17 14:51:36 -04:00 committed by GitHub
parent a24b6daa87
commit a21700a444
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -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") {