错误:
所请求的资源上没有“ Access-Control-Allow-Origin”标头。因此,不允许访问来源“ https://abcd.com”。响应的HTTP状态码为403。
每当我尝试从Angular 4发出http发布请求时,我都会收到上述错误。我正在以JSON正文发送汉字并且已经允许
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
httpServletResponse.setHeader("Access-Control-Max-Age", "3600");
httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true");
httpServletResponse.setHeader("Access-Control-Allow-Headers","Accept,x-requested-with, authorization, Content-Type, Authorization, credential, X-XSRF-TOKEN,Cache-Control,Content-Type,Keep-Alive,Origin,User-Agent,X-Requested-With,charset=utf-8");
每次发布汉字时都会遇到此问题。
答案 0 :(得分:1)
Access-Control-Allow-Headers可能是导致此问题的原因-尝试将Access-Control-Allow-Headers的值设置为*