A platform for community discussion. Free, open, simple.
FIX: ember-cli proxy subfolder fix (#12996)
Jeff Wongd61573fb1b87
diff --git a/app/assets/javascripts/discourse/config/environment.js b/app/assets/javascripts/discourse/config/environment.jsindex e004e1eaba2..f9672557d97 100644--- a/app/assets/javascripts/discourse/config/environment.js+++ b/app/assets/javascripts/discourse/config/environment.js@@ -4,7 +4,7 @@ module.exports = function (environment) {let ENV = {modulePrefix: "discourse",environment,- rootURL: "/",+ rootURL: process.env.DISCOURSE_RELATIVE_URL_ROOT || "/",locationType: "auto",historySupportMiddleware: false,EmberENV: {diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js b/app/assets/javascripts/discourse/lib/bootstrap-json/index.jsindex 0e8b503a223..3b97c65d419 100644--- a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js+++ b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js@@ -155,26 +155,28 @@ function applyBootstrap(bootstrap, template, headers) {return template;}-function buildFromBootstrap(assetPath, proxy, req, headers) {+function buildFromBootstrap(assetPath, proxy, baseURL, req, headers) {// eslint-disable-next-linereturn new Promise((resolve, reject) => {fs.readFile(path.join(process.cwd(), "dist", assetPath),"utf8",(err, template) => {- getJSON(`${proxy}/bootstrap.json`, null, req.headers)+ getJSON(`${proxy}${baseURL}bootstrap.json`, null, req.headers).then((json) => {resolve(applyBootstrap(json.bootstrap, template, headers));}).catch((e) => {- reject(`Could not get ${proxy}/bootstrap.json\n\n${e.toString()}`);+ reject(+ `Could not get ${proxy}${baseURL}bootstrap.json\n\n${e.toString()}`+ );});});});}-async function handleRequest(assetPath, proxy, req, res) {+async function handleRequest(assetPath, proxy, baseURL, req, res) {if (assetPath.endsWith("tests/index.html")) {return;}@@ -200,6 +202,7 @@ async function handleRequest(assetPath, proxy, req, res) {let json = await buildFromBootstrap(assetPath,proxy,+ baseURL,req,response.headers);@@ -264,7 +267,7 @@ to serve API requests. For example:if (!isFile) {assetPath = "index.html";}- await handleRequest(assetPath, proxy, req, res);+ await handleRequest(assetPath, proxy, baseURL, req, res);}} finally {if (!res.headersSent) {@@ -274,7 +277,7 @@ to serve API requests. For example:});},- shouldHandleRequest(req, options) {+ shouldHandleRequest(req) {let acceptHeaders = req.headers.accept || [];let hasHTMLHeader = acceptHeaders.indexOf("text/html") !== -1;if (req.method !== "GET") {@@ -292,11 +295,7 @@ to serve API requests. For example:return false;}- let baseURL =- options.rootURL === ""- ? "/"- : cleanBaseURL(options.rootURL || options.baseURL);- let baseURLRegexp = new RegExp(`^${baseURL}`);+ let baseURLRegexp = new RegExp(`^/`);return baseURLRegexp.test(req.path);},};