I want to do some ember routing from another domain: Example:
m.site.com/foo
site.com/path/to/ember/bar
So, I have to change the root path "on the fly", depending on which domain the script is executed
I'm trying to add rootURLinEmber.Router
var Router = Ember.Router.extend({
location: 'hash'
rootURL: '/path/to/ember/'
});
and change app-config-from-meta.js in ember-cli
try {
var metaName = prefix + '/config/environment';
var rawConfig = Ember['default'].$('meta[name="' + metaName + '"]').attr('content');
var config = JSON.parse(unescape(rawConfig));
if (window.location.href.indexOf('m.') !== -1) {
config.baseURL = '/path/to/ember/';
config.locationType = 'hash';
}
console.log(config);
return { 'default': config };
}
catch(err) {
throw new Error('Could not read config from meta tag with name "' + metaName + '".');
}
but it doesn’t help.
Update:
The problem was in the tag '<base href="' + baseURL + '">'that was inserted during the build. Therefore, since I understand that I need to create an alternative index file, for example, index.htmland index_bar.html. What is easier to do with it?
Update: My awareness: Added to broccoli-config-replaceaction process.
if (filePath.indexOf('index_bar.html') > 0){
var tmpConfig = config;
tmpConfig.baseURL = config._chatBaseURL;
tmpConfig.locationType = config._chatLocationType;
this.processFile(tmpConfig, filePath, destPath);
} else {
this.processFile(config, filePath, destPath);
}
index.htmlworks with autorouting and base/
index_bar.htmlworks with hashrouting and base/path/to/ember/
Any better solution? Thanks