Skip to content

Commit

Permalink
[FIX] Theme CSS loading in subdir env (#14015)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Apr 6, 2019
1 parent c8b0262 commit 54cac43
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/theme/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Inject } from 'meteor/meteorhacks:inject-initial';

import { settings } from '../../settings';
import { Logger } from '../../logger';
import { getURL } from '../../utils/lib/getURL';

const logger = new Logger('rocketchat:theme', {
methods: {
Expand Down Expand Up @@ -78,10 +79,6 @@ export const theme = new class {
}
settings.updateById('css', data.css);

currentHash = crypto.createHash('sha1').update(data.css).digest('hex');
currentSize = data.css.length;
Inject.rawHead('css-theme', `<link rel="stylesheet" type="text/css" href="/theme.css?${ currentHash }">`);

return Meteor.startup(function() {
return Meteor.setTimeout(function() {
return process.emit('message', {
Expand Down Expand Up @@ -157,6 +154,12 @@ export const theme = new class {
}
};

settings.get('css', (key, value = '') => {
currentHash = crypto.createHash('sha1').update(value).digest('hex');
currentSize = value.length;
Inject.rawHead('css-theme', `<link rel="stylesheet" type="text/css" href="${ getURL(`/theme.css?${ currentHash }`) }">`);
});

WebApp.rawConnectHandlers.use(function(req, res, next) {
const path = req.url.split('?')[0];
const prefix = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '';
Expand Down

0 comments on commit 54cac43

Please sign in to comment.