Angular2对预检的响应来自某些GET请求无效(重定向) [英] Angular2 Response for preflight is invalid (redirect) from some GET requests
问题描述
我正在使用Angular2,与rest API通信,并按如下方式设置标头:
I am using Angular2, Communicating with a rest API, settings the header like so:
import { Headers } from '@angular/http';
export const contentHeaders = new Headers();
contentHeaders.append('Accept', 'application/json');
contentHeaders.append('Content-Type', 'application/json');
contentHeaders.append('Authorization', localStorage.getItem('id_token'));
像items/
这样的获取请求和POST请求都可以,但是当对一项进行GET请求时,例如:items/579212a6541d5626732619c3
服务器响应服务器错误Response for preflight is invalid (redirect)
Get request like items/
and POST request works, but when making GET requests for one item, like: items/579212a6541d5626732619c3
the server respond with a server error Response for preflight is invalid (redirect)
我认为这些获取请求是相同的,但也许它们不是吗?有解决方案吗?
I thought those get requests are the same, but maybe they are not ? Any solutions ?
推荐答案
重定向+表示您可能正在从该特定请求中重定向.您确定在后端正确处理了商品的ID吗?
Redirect + says that you are probably being redirected from that particular request. Are you sure that the ID of item is handled correctly on a backend?
这篇关于Angular2对预检的响应来自某些GET请求无效(重定向)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!