在本地运行时,如何在 Azure 静态网站托管(预览版)中传递“x-ms-client-principal”?

Ori*_*ian 5 azure reactjs azure-functions azure-static-website-hosting

我正在尝试新的 Azure 静态网站托管预览版,在本地运行时,Azure 函数未接收 req 绑定对象中的“x-ms-client-principle”标头。

我的路线文件如下所示:

{
  "routes": [
    {
      "route": "/api/*",
      "allowedRoles": ["administrator"]
    },
    {
      "route": "/*",
      "serve": "/index.html",
      "statusCode": 200
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我的 API 函数在: 处受到攻击/api/message,但不包括标头。

module.exports = async function (context, req) {
  const header = req.headers["x-ms-client-principal"]; // req.headers doesn't include x-ms-client-principle
  const encoded = Buffer.from(header, "base64");
  const decoded = encoded.toString("ascii");
}
Run Code Online (Sandbox Code Playgroud)

静态应用程序是使用 create-react-app 创建的 React 静态页面。我有一行可以打印出反应应用程序的结果:

fetch(`${process.env.REACT_APP_API}/message?name=me`)
  .then(a => a.text())
  .then(console.log);
Run Code Online (Sandbox Code Playgroud)

本地process.env.REACT_APP_API通过 进行设置REACT_APP_API=http://127.0.0.1:7071/api

API 受到攻击,但我不确定它是否运行正确版本的 Azure Functions。它报告:Function Runtime Version: 2.0.12961.0即使我已经安装了 azure-functions-core-tools@3,并"azureFunctions.projectRuntime": "~3"settings.json.

我的问题是我是否遗漏了一些东西,如果是的话,是什么?

Ori*_*ian 2

目前,这似乎不是受支持的场景:

https://github.com/MicrosoftDocs/azure-docs/issues/55517