-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subdomains #62
Comments
We disabled subdomain routing because it was useless and not used in 99.99% of cases. Every request contains a |
I need different subdomains to link to different routes, but it seems this can't be achieved in Total4? |
Hmm. I'm looking at the source code, and maybe it works with subdomain routing. I'm not sure if this works. // Route with flags
ROUTE('[eshop,store]/', action);
// e.g. http://eshop.totaljs.com/
// e.g. http://store.totaljs.com/
ROUTE('[*]/', action);
// All subdomains
ROUTE('[nice*]/', action);
// All subdomains which contain `nice` word We removed this functionality in Total.js v5. If the above solution will not work, then you can try something like this: ON('request', function(req) {
// This property is used for routing:
// req.uri.pathname = '/home/';
}); |
I'll give it a try, thank you very much. |
I also looked at the source code. This only exists in the v3 version. It seems that v4 does not support such usage. |
Although it lacks documentation, we implemented it for backward compatibility with Total.js v3. I hope it works: |
ROUTE('GET /', function(){this.json('index')});
ROUTE('GET [admin]/', function(){this.json('admin')});
ROUTE('GET [foliko]/', function(){this.json('foliko')}); I tried this method, but it doesn't seem to work. |
I'll test it today and I'll try to fix it. |
I have looked at it and it's not implemented in the routing mechanism. I have checked possible implementation and it's really complicated. Maybe you can try something like this: exports.install = function() {
ROUTE('GET /', subdomain({
admin: funtion() {
this.json('admin');
},
foliko: funtion() {
this.json('foliko');
}
}));
};
function subdomain(map) {
return function() {
var self = this;
var subdomain = self.subdomain ? self.subdomain.join('.') : null;
if (subdomain) {
for (var key in map) {
if (subdomain === key) {
map[key].apply(self, arguments);
return;
}
}
}
self.invalid(404);
};
} The |
Okay, thank you very much, I'll give it a try |
Hello, how to dynamically link to different subdomains, I can't find any way to achieve it
The text was updated successfully, but these errors were encountered: