zoukankan      html  css  js  c++  java
  • 请求服务器报错 Access-Control-Allow-Origin

    今天遇到一个问题,发送请求能够成功了,返回的数据也能在 network 中看见,但是报错:

    Access to XMLHttpRequest at 'http://192.168.200.112:8080/lottery/getIsWinLottery?Id=966&succ7F0D92C70492DCD' from origin 'http://192.168.200.196' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

    请求状态码为200,在 network 中也能看到返回的数据,但是控制台没有打印信息。

    搜了半天发现了解决方案:

    withCredentials: false, // 允许携带cookie

    其他方案都需要后端调配置。

     

    Failed to load http://pre.api.jmxy.mockuai.c...: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://pre.promotion.jmxy.moc...' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

  • 相关阅读:
    A1015. Reversible Primes (20)
    A1024. Palindromic Number (25)
    A1023. Have Fun with Numbers (20)
    B1017. A除以B (20)
    A1059. Prime Factors (25)
    阵列命令
    工具面板
    圆角与镜像命令
    拉伸与缩放命令
    autium designer
  • 原文地址:https://www.cnblogs.com/joe235/p/13374284.html
Copyright © 2011-2022 走看看