Skip to content

Commit

Permalink
Merge pull request #7395 from ryoshimizu/fix-file-upload-broken-when-…
Browse files Browse the repository at this point in the history
…running-in-subdir-6679

[FIX] file upload broken when running in subdirectory https://github.com…
  • Loading branch information
rodrigok authored Jul 14, 2017
2 parents eeb773a + 6de7e46 commit 2fec4d8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/rocketchat-cors/cors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import url from 'url';

WebApp.rawConnectHandlers.use(function(req, res, next) {
WebApp.rawConnectHandlers.use(Meteor.bindEnvironment(function(req, res, next) {
if (req._body) {
return next();
}
Expand All @@ -12,7 +12,7 @@ WebApp.rawConnectHandlers.use(function(req, res, next) {
if (req.headers['content-type'] !== '' && req.headers['content-type'] !== undefined) {
return next();
}
if (req.url.indexOf('/ufs/') === 0) {
if (req.url.indexOf(`${ __meteor_runtime_config__.ROOT_URL_PATH_PREFIX }/ufs/`) === 0) {
return next();
}

Expand All @@ -36,7 +36,7 @@ WebApp.rawConnectHandlers.use(function(req, res, next) {

return next();
});
});
}));

WebApp.rawConnectHandlers.use(function(req, res, next) {
if (/^\/(api|_timesync|sockjs|tap-i18n|__cordova)(\/|$)/.test(req.url)) {
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-file-upload/server/lib/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ RocketChat.settings.get('FileUpload_ProtectFiles', function(key, value) {
protectedFiles = value;
});

WebApp.connectHandlers.use('/file-upload/', function(req, res, next) {
WebApp.connectHandlers.use(`${ __meteor_runtime_config__.ROOT_URL_PATH_PREFIX }/file-upload/`, function(req, res, next) {

const match = /^\/([^\/]+)\/(.*)/.exec(req.url);

if (match[1]) {
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-lib/client/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Meteor.startup(function() {
return c.stop();
}
Meteor.setTimeout(function() {
if (__meteor_runtime_config__.ROOT_URL !== location.origin) {
const currentUrl = location.origin + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
const currentUrl = location.origin + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
if (__meteor_runtime_config__.ROOT_URL !== currentUrl) {
swal({
type: 'warning',
title: t('Warning'),
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ RocketChat.settings.get('Site_Url', function(key, value) {
host = match[1];
// prefix = match[2].replace(/\/$/, '');
}
__meteor_runtime_config__.ROOT_URL = host;
__meteor_runtime_config__.ROOT_URL = value;

if (Meteor.absoluteUrl.defaultOptions && Meteor.absoluteUrl.defaultOptions.rootUrl) {
Meteor.absoluteUrl.defaultOptions.rootUrl = host;
Meteor.absoluteUrl.defaultOptions.rootUrl = value;
}
if (Meteor.isServer) {
RocketChat.hostname = host.replace(/^https?:\/\//, '');
Expand Down

0 comments on commit 2fec4d8

Please sign in to comment.