Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hubs Cloud Hotfix] Add fix for cloudflare custom clients #5136

Merged
merged 5 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion admin/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ module.exports = (env, argv) => {
RETICULUM_SERVER: process.env.RETICULUM_SERVER,
CORS_PROXY_SERVER: process.env.CORS_PROXY_SERVER,
POSTGREST_SERVER: process.env.POSTGREST_SERVER,
UPLOADS_HOST: process.env.UPLOADS_HOST
UPLOADS_HOST: process.env.UPLOADS_HOST,
BASE_ASSETS_PATH: process.env.BASE_ASSETS_PATH
})
})
]
Expand Down
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
3 changes: 2 additions & 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 Expand Up @@ -645,6 +645,7 @@ module.exports = async (env, argv) => {
GA_TRACKING_ID: process.env.GA_TRACKING_ID,
POSTGREST_SERVER: process.env.POSTGREST_SERVER,
UPLOADS_HOST: process.env.UPLOADS_HOST,
BASE_ASSETS_PATH: process.env.BASE_ASSETS_PATH,
APP_CONFIG: appConfig
})
})
Expand Down