Here is my /etc/hosts file
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 test.localhost
127.0.0.1 demo.localhost
127.0.0.1 test2.localhost
255.255.255.255 broadcasthost
::1 localhost
Run Code Online (Sandbox Code Playgroud)
我需要的是能够从url中解析子域,因为我必须将它存储在会话cookie中供会话使用(现在).我不想做任何花哨的事 - 比如现在设置api或任何东西.
Express的文档显示有一个req.subdomains属性将子域列为数组,但是对于所有本地子域,此数组显示为空.[即当我去demo.localhost:3000时,Web应用程序肯定会提供,但在第一个get函数中,我调用req.subdomains并且有一个空数组[].
如何从我的localhost:3000获取这些子域字符串?
Exp*_*lls 12
这是因为您的主机缺少TLD. 从Express代码 - 子域偏移将默认为2,因为它期望类似.com而不是主机结束localhost.
您可以将其this.app.set('subdomain offset', 1);用作本地运行的配置的一部分.
| 归档时间: |
|
| 查看次数: |
1723 次 |
| 最近记录: |