Get current domain name from request in Nuxt

橙三吉。 提交于 2019-12-24 11:24:29

问题


How can I get the current domain name from a request on server side?

My Nuxt based website is reachable from different domains. I would like to get the domain name from where the user has accessed the website. How can I do this?

I tried to write a middleware for that purpose but it always displays localhost:3000

export default function({ store, req }) {
  if (process.server) store.commit('hostname', req.headers.host)
}

Any idea how to fix this issue?

来源:https://stackoverflow.com/questions/56854595/get-current-domain-name-from-request-in-nuxt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!