weixin_33714884 2017-08-11 04:44 采纳率: 0%
浏览 88

Node.js上的Ajax请求错误

I have a node.js server running on port 3000 and in my index.html file on that server, I send a Ajax request to apache2 server on port 80 to retrieve the current cookie on the site. However, I get no cookie response even though I see the cookie on my browser. My Ajax request on index.html:

$.ajax ({
        type: "GET",
        url: "http://103.57.220.117:80/chatroom/api/auth",
        async: false,
        global: false,
        processData: false,
        contenType: "application/json",
        data: "",
        success: function(r) {
            console.log(r)
        },
        error: function(r) {
            console.log(r)
        }
}); 

In my index.php endpoint on my api file:

if ($_SERVER['REQUEST_METHOD'] == 'GET') {

if ($_GET['url'] == 'auth') {

    $cookie= $_COOKIE['SNID'];
    echo '{ "cookie" : '.$cookie.' }';
    http_response_code(200);

}

}

The api response with the 200 code but no cookie

However, on the browser there is cookie displayed and active (cookie on browser)

Is there any way to fix this? I really need solution because this is very important for my school project

  • 写回答

1条回答 默认 最新

  • weixin_33682719 2017-08-11 06:20
    关注

    Cookies can not be shared across sites, this includes sites on the same domain but using different ports.

    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真