我正在向我的计算机(192.168.1.132)上的API请求我的手机(在同一网络中)做出反应:
fetch('http://192.168.1.132:8000/test',{ method: 'GET',headers: { 'Authorization': 'Bearer 4uFPmkP5326DXcRuHDKjRRrmhdeIBJ'},credentials: 'same-origin' }) .then((response) => response.json()) .then((responseJson) => { console.log('RESPONSE: ' + JSON.stringify(responseJson)) })
但我正在嗅探请求并且它没有Authorization标头(我放的任何其他标题都会出现,但不是授权).在Xcode中,我启用了“AllowArbitraryLoads”.所以我的API返回401(未授权),因为很明显没有授权标头.为什么它不包括在我的请求中?