【问题标题】:How do we get the url typed in the browser in the server files?我们如何在服务器文件中获取在浏览器中输入的 url?
【发布时间】:2021-10-04 15:30:37
【问题描述】:

我们如何在javascript中的服务器端(服务器文件)中获取我们在浏览器中输入的url?我使用的 Web 框架是 React。我不能使用window.location.href,因为窗口对象只能在浏览器端使用。

【问题讨论】:

  • 太宽泛了,umm 在req 对象中
  • 如前所述,这非常广泛。试试document.window.location.href

标签: javascript node.js reactjs url window.location


【解决方案1】:

window 是一个浏览器 API,它在 node 上不存在,但你可以做的是通过 POST 请求将 window.location.href 发送到服务器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-19
    • 2011-05-05
    • 1970-01-01
    • 1970-01-01
    • 2012-10-16
    相关资源
    最近更新 更多