我有一个带有多个端点的 .netcore Web API 应用程序,并且我有一个简单的 UI,用于使用 javascript fetch API 单击按钮来访问端点。
fetch('api/Sessions', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(callData)
})
.then(response => response.text())
.then((response) => updateResponse(response))
.catch(error => console.error(error));
}
Run Code Online (Sandbox Code Playgroud)
现在控制器中的 API 端点已使用 API-KEY 进行身份验证, [ServiceFilter(typeof(AuthorizeKey))]我无法再从 UI 访问该端点。如何更改 HTML/javascript 代码以便将 post 请求从我的 UI 发送到经过身份验证的端点?谢谢