在和后台人员关于接口token的设置,我放在请求header中
结果,放到线上,请求报错:
Access to XMLHttpRequest at 'https://*******/Login/login' from origin '********' has been blocked by CORS policy: Request header field x-token is not allowed by Access-Control-Allow-Headers in preflight response.
一直以为是跨域的,后台能改的都改了。结果查资料才知道,是请求header中设置的x-token,在返回header中没有,将response的header里加上x-token就可以了。
浪费了好长时间,心好累