0
this._service.get('/api/user').subscribe(user => {
})
服務器
app.use('/api/user', function(req){
console.log(req.hostname) //always get localhost
})
如果我的支票isBrowser沒有問題,就可以得到主機名
if(isBrowser)
{
this._service.get('/api/user').subscribe(user => {
this.store.dispatch({ type: SETUSER, payload: user })
})
}
如何在後端渲染獲取主機名
你想要得到什麼?本地主機連同端口號?添加您的期望值以及您當前獲得的價值。 – Aravind
我得到本地主機。我想要域名(* .com) –