我试图用下面的方法在角6中创建子域。
例如,:
本地主机:4200
client1.localhost:4200
client2.localhost:4200
getSubdomain() {
const domain = window.location.hostname;
if (domain.indexOf('.') < 0
|| domain.split('.')[0] === 'example'
|| domain.split('.')[0] === 'lvh'
|| domain.split('.')[0] === 'www') {
this.subdomain = '';
} else {
this.subdomain = domain.split('.')[0];
}
console.log('subdomain', this.subdomain);
}请建议我任何其他选择,以创建一个角6的子域。
发布于 2019-05-28 10:03:16
出于开发目的,您可以在etc/host文件中添加子域(C:\Windows\System32 32\驱动器\etc\host),如下所示。
127.0.0.1 client1
::1 client1
127.0.0.1 client2
::1 client2使用命令送达应用程序:-
ng serve --host client1 --port 4300 --open
ng serve --host client2 --port 4400 --openhttps://stackoverflow.com/questions/56339417
复制相似问题