流星中的子域支持(如松弛-http://team.slack.com) [英] subdomain support in meteor (like with slack - http://team.slack.com)

查看:50
本文介绍了流星中的子域支持(如松弛-http://team.slack.com)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

流星中的子域支持(如松弛- http://team.slack.com )

subdomain support in meteor (like with slack - http://team.slack.com)

就像闲暇一样,我的应用程序用户可以创建自己的子域(唯一),并根据子域来加载数据,然后围绕该子域继续进行应用程序.我可以使用 http://slack.com?team=TeamName 之类的东西,但是我认为该子域会变得更干净更好.

As in slack my app users can create their own subdomains (unique) and depending on the subdomain the data should be loaded, and around this the application would be proceeded. I can use something like http://slack.com?team=TeamName, but i think the subdomain would be much clean and better.

任何建议/指针.

谢谢.

推荐答案

来自使用DNS通配符将* .example.com指向我的应用服务器,我将其包含在客户端代码中:

Using a DNS wildcard to point *.example.com to my app server, I have this in the client code:

var hostnameArray = document.location.hostname.split( "." );

if ( hostnameArray[1] === "example" && hostnameArray[2] === "com" ) {
  var subdomain = hostnameArray[0];  
}

if ( subdomain ) {
  Meteor.call( "findTeamBySubdomain", subdomain, function (err, res) {
    var teamId = res;
    if ( teamId )
      Session.set( "teamId", teamId ); 
    }
  });
}

Tracker.autorun ( function () {
  Meteor.subscribe( "teamInfo", Session.get( "teamId" ) );
});


确保当前登录的用户具有查看teamId发布记录的权限.任何人都可以调整其会话并说我属于这个团队".您需要确保它们确实被允许.


Make sure the currently signed in user has permission to view the teamId publication records. Anybody can tweak their session and say "I belong to this team." You need to make sure they are actually allowed.

这篇关于流星中的子域支持(如松弛-http://team.slack.com)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆