removed x-rewriter-url

This commit is contained in:
Alexey Bannov 2023-05-03 20:25:50 +03:00
parent 658ac5102f
commit c61c938729
5 changed files with 15 additions and 33 deletions

View File

@ -1,21 +1,6 @@
//const conf = require("../config");
//const portalInternalUrl = conf.get("core")["base-domain"] === "localhost" ? "http://localhost" : ""; //Do not use base-domain for portalInternalUrl
module.exports = (req) => {
//if (portalInternalUrl) return portalInternalUrl; //TODO: Fix internal api url setup after external api domain complete
module.exports = (req) => {
const proto = req.headers['x-forwarded-proto']?.split(',').shift();
const host = req.headers['x-forwarded-host']?.split(',').shift();
const xRewriterUrlInternalHeader = "x-rewriter-url-internal";
if (req.headers && req.headers[xRewriterUrlInternalHeader]) {
return req.headers[xRewriterUrlInternalHeader];
}
const xRewriterUrlHeader = "x-rewriter-url";
if (req.headers && req.headers[xRewriterUrlHeader]) {
return req.headers[xRewriterUrlHeader];
}
if (req?.headers?.origin) {
return req.headers.origin;
}
return "";
return `${proto}://${host}`;
};

View File

@ -25,8 +25,10 @@ const config = require("../../config").get(),
module.exports = function () {
function getBaseUrl(req) {
const url = req.headers["x-rewriter-url"] || req.protocol + "://" + req.get("host");
return url;
const proto = req.headers['x-forwarded-proto']?.split(',').shift();
const host = req.headers['x-forwarded-host']?.split(',').shift();
return `${proto}://${host}`;
}
function getPortalSsoHandlerUrl(req) {

View File

@ -37,15 +37,10 @@ const renamingDuplicateElements = require('../helper/renamingDuplicateElements.j
function getDomain(ctx) {
const rewriterUrl = ctx.headers.headers["x-rewriter-url"];
const proto = ctx.headers.headers['x-forwarded-proto']?.split(',').shift();
const host = ctx.headers.headers['x-forwarded-host']?.split(',').shift();
if (rewriterUrl) {
return rewriterUrl;
}
const protocol = isHttps ? "https://" : "http://";
const hostStr = ctx.headers.host;
return protocol + hostStr.split(":")[0] + onlyOfficePort;
return `${proto}://${host}`;
}
function instanceFunc(ctx, token = null, header = 'application/json', service = 'asc.files') {

View File

@ -90,7 +90,6 @@ server {
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header Proxy "";

View File

@ -57,9 +57,10 @@ class AxiosClient {
initSSR = (headers) => {
this.isSSR = true;
const xRewriterUrl = headers["x-rewriter-url"];
const origin = apiOrigin || xRewriterUrl;
const proto = headers['x-forwarded-proto']?.split(',').shift();
const host = headers['x-forwarded-host']?.split(',').shift();
const origin = apiOrigin || `${proto}://${host}`;
const apiBaseURL = combineUrl(origin, proxyURL, apiPrefix);