我正在使用基于令牌的Lambda授权器,如下所述: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
现在我仍在使用玩具示例,其中标题道具为tokenHeader
我的提取如下:
export function logout() {
return (dispatch,getState) => {
return fetch('https://account-api.example.com/v1/logout',{
method: 'GET',headers: {
'access-Control-Request-Method': 'GET','access-Control-Request-Headers': 'Content-Type,Authorization','Content-Type': 'application/json','tokenHeader':'allow',},credentials: 'include'
})
.then((response) => {
return response.json().then((body) => {
return {
status: body.statusCode,payload:body.payload,};
},);
})
.then((response) => {
console.log("response",response)
if (response.status !== 200) {
dispatch({ type: 'LOGOUT_ERROR',payload: response.payload.error});
}
if (response.status === 200) {
dispatch({ type: 'LOGOUT_SUCCESSFUL',payload: response.payload });
}
})
.catch(error => {
dispatch({ type: 'LOGOUT_FAILED',payload: String(error)});
})
};
}
当我查看网络标签时,我的请求中缺少'tokenHeader':'allow'
标头,导致授权者显示401-我该怎么做才能防止此标头被剥夺?
旁注:此请求适用于邮递员
API网关配置(不确定是否相关):
我不想忽略CORS并在account-api.example.com
和dev.example.com
之间发送数据,因此请不要提供任何指示以删除/忽略cors的答案-我的目标是正确实现cors。