[REF] web: remove useless rpc/fetch patching code
Previously, when creating the public root, we would patch the rpc service and the browser.fetch function so that they would rewrite the relative URLs that they fetched to target the Odoo server. This is useful when the public root is mounted on pages that are hosted on a different server than the Odoo server, in particular, this was historically useful for embeding the livechat widget in a website not hosted by Odoo. In odoo/odoo#122834 the livechat was refactored and got its own boot code that does the same thing, making this code no longer useful. In addition, in odoo/odoo#133153 the baseUrl we use no longer refers to the session prefix which was configured by the livechat previously, but simply refers to the origin of the page where the code is hosted, making it a no-op. These factors mean that the code removed by this commit is now completely useless, which is why this commit removes it. closes odoo/odoo#136672 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -18,11 +18,9 @@ import { makeEnv, startServices } from "@web/env";
|
||||
import { loadJS, templates } from '@web/core/assets';
|
||||
import { MainComponentsContainer } from "@web/core/main_components_container";
|
||||
import { browser } from '@web/core/browser/browser';
|
||||
import { jsonrpc } from '@web/core/network/rpc_service';
|
||||
import { renderToString } from "@web/core/utils/render";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { App, whenReady } from "@odoo/owl";
|
||||
import { getOrigin } from '@web/core/utils/urls';
|
||||
|
||||
const { Settings } = luxon;
|
||||
|
||||
@@ -334,35 +332,6 @@ export async function createPublicRoot(RootWidget) {
|
||||
serviceRegistry.add(legacyServiceName, wowlToLegacyServiceMapper(legacyEnv));
|
||||
}
|
||||
await whenReady();
|
||||
|
||||
// Patch browser.fetch and the rpc service to use the correct base url when
|
||||
// embeded in an external page
|
||||
const baseUrl = getOrigin();
|
||||
const { fetch } = browser;
|
||||
browser.fetch = function(url, ...args) {
|
||||
if (!url.match(/^(?:https?:)?\/\//)) {
|
||||
url = baseUrl + url;
|
||||
}
|
||||
return fetch(url, ...args);
|
||||
}
|
||||
serviceRegistry.add("rpc", {
|
||||
async: true,
|
||||
start(env) {
|
||||
return function rpc(route, params = {}, settings = {}) {
|
||||
if (!route.match(/^(?:https?:)?\/\//)) {
|
||||
route = baseUrl + route;
|
||||
}
|
||||
if (String(route).includes("/web/dataset/call_kw/")) {
|
||||
params.kwargs.context = {
|
||||
...publicRoot._getContext(),
|
||||
...params.kwargs.context,
|
||||
};
|
||||
}
|
||||
return jsonrpc(route, params, { bus: env.bus, ...settings });
|
||||
};
|
||||
},
|
||||
}, { force: true });
|
||||
|
||||
const wowlEnv = makeEnv();
|
||||
|
||||
await startServices(wowlEnv);
|
||||
|
||||
Reference in New Issue
Block a user