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