I'm trying out the new Azure Static Website Hosting Preview and when running locally, the Azure functions aren't receiving the "x-ms-client-principle" header in the req binding object.
My routes file looks like:
{
"routes": [
{
"route": "/api/*",
"allowedRoles": ["administrator"]
},
{
"route": "/*",
"serve": "/index.html",
"statusCode": 200
}
]
}
My API function is getting hit at: /api/message
, but isn't including the header.
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");
}
The static app is a React static page created with create-react-app. I have a line to print out the result from the react-app:
fetch(`${process.env.REACT_APP_API}/message?name=me`)
.then(a => a.text())
.then(console.log);
Locally process.env.REACT_APP_API
is set via REACT_APP_API=http://127.0.0.1:7071/api
.
The API is getting hit, but I'm not sure if it's running the correct version of Azure Functions. It is reporting: Function Runtime Version: 2.0.12961.0
even though I've installed azure-functions-core-tools@3, and set the proper value ("azureFunctions.projectRuntime": "~3"
) in settings.json
.
My question is am I missing something, and if so, what?