Node-RED:如何在 "HTTP In" 节点中获取 URL "fragment"?

Node-RED: how do I get the URL "fragment" within a "HTTP In" node?

我目前正在尝试实现一个小型 HTTP(S) 服务器以进行测试。

因此我还需要传入请求的 URL“片段”(即“#”之后的任何文本)。

但是,看起来,片段在到达“HTTP In”节点之前在 Node-RED 中的某处被吞没了:根据调试输出,msg.req._parsedURL.hashmsg.req._parsedOriginalURL.hash 都是 null.

那么,我该如何检索片段呢?

你没有

片段全部在浏览器中处理,URL的那部分永远不会发送到后端服务器。

浏览器永远不会将 URL 片段发送到服务器,因此您无法访问它。

来自w3 spec

Interpretation of the fragment identifier is performed solely by the agent that dereferences a URI; the fragment identifier is not passed to other systems during the process of retrieval. This means that some intermediaries in Web architecture (such as proxies) have no interaction with fragment identifiers and that redirection (in HTTP [RFC2616], for example) does not account for fragments.