Skip to content

Commit

Permalink
Merge pull request #5146 from mozilla/fix-assets-and-uploads
Browse files Browse the repository at this point in the history
[Hubs Cloud] Fix local assets path and upload proxy for localhost
  • Loading branch information
brianpeiris authored Feb 17, 2022
2 parents cbf3ca2 + f35028a commit 7a21cc6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/utils/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ let isAdmin = false;
const el = document.querySelector(`meta[name='env:${x.toLowerCase()}']`);
configs[x] = el ? el.getAttribute("content") : process.env[x];

if (x === "BASE_ASSETS_PATH" && configs[x]) {
const BASE_ASSETS_PATH_KEY = "BASE_ASSETS_PATH";
if (x === BASE_ASSETS_PATH_KEY && configs[BASE_ASSETS_PATH_KEY]) {
// BASE_ASSETS_PATH might be a relative URL like "/" when it is set in
// .env or .defaults.env when running locally. We need to convert that
// to an absolute URL.
if (!configs[BASE_ASSETS_PATH_KEY].startsWith("http")) {
configs[BASE_ASSETS_PATH_KEY] = new URL(configs[BASE_ASSETS_PATH_KEY], window.location).toString();
}

// eslint-disable-next-line no-undef
__webpack_public_path__ = configs[x];
__webpack_public_path__ = configs[BASE_ASSETS_PATH_KEY];
}
});

Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ module.exports = async (env, argv) => {
if (req.method === "OPTIONS") {
res.send();
} else {
const url = req.path.replace("/cors-proxy/", "");
const url = req.originalUrl.replace("/cors-proxy/", "");
request({ url, method: req.method }, error => {
if (error) {
console.error(`cors-proxy: error fetching "${url}"\n`, error);
Expand Down

0 comments on commit 7a21cc6

Please sign in to comment.