0

I'm currently working with Angular 5.1.2 and i'm trying to get objects from http requests. In order to verify my code, I've hardcoded a JSON response and created a Python Anywhere's web service, here's what I did :

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=UTF-8
{"Computer":[{
"ip":"192.168.0.142",
"mac":"39-D7-98-9E-5A-DC",
"name":"PC-DE-JEAN-CLAUDE"
},
{
"ip":"192.168.0.50",
"mac":"4D-49-98-30-8A-F5",
"name":"LIVEBOX-684J"
}]} 

However, why my Angular app is saying that "No 'Access-Control-Allow-Origin' header is present on the requested resource" ? Thanks

Tolemack
  • 47
  • 3

2 Answers2

1

It is related to CORS issue. It happens when server and client are running on different addresses. To make it run, server need to return Access-Control-Allow-Origin as a Key:Value pair in their header response.

Access-Control-Allow-Origin: *

Specifying value as * means that the content of the address can be accessed by any other address.

It's one of the layer in securing the Internet applications.

Ajay
  • 4,773
  • 3
  • 23
  • 36
0

This is a server-side problem due to CORS to prevent XSS. In order to fix, make sure your server responds with the header Access-Control-Allow-Origin: * After verifying this fixes the problem, set this header to your website URL

Wolf
  • 52
  • 3