The Laravel 5.3 API has been configured to complete
//category.service.ts private headers = new Headers({'Content-Type': 'application/json','Accept':'application/json','Authorization':'Bearer '+window.localStorage.getItem('token')}); private heroesUrl = 'http://xingao.5188cms.com/api/user'; // URL to web api private handleError(error: any): Promise { console.error('An error occurred', error); // for demo purposes only return Promise.reject(error.message || error); }
This way to access, hint XMLHttpRequest cannot load http://xingao.5188cms.com/api/user. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
, it seems to be a cross-domain problem, but I use postman can be successfully obtained data
Step Two
I replaced the link with ahttp://xingao.5188cms.com/test.php
//test.php
Or not?XMLHttpRequest cannot load http://xingao.5188cms.com/test.php. Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
Step Three
I changed the link to one /test.json
, but I can.
What is the reason for that ....
Reply content:
The Laravel 5.3 API has been configured to complete
//category.service.ts private headers = new Headers({'Content-Type': 'application/json','Accept':'application/json','Authorization':'Bearer '+window.localStorage.getItem('token')}); private heroesUrl = 'http://xingao.5188cms.com/api/user'; // URL to web api private handleError(error: any): Promise { console.error('An error occurred', error); // for demo purposes only return Promise.reject(error.message || error); }
This way to access, hint XMLHttpRequest cannot load http://xingao.5188cms.com/api/user. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
, it seems to be a cross-domain problem, but I use postman can be successfully obtained data
Step Two
I replaced the link with ahttp://xingao.5188cms.com/test.php
//test.php
Or not?XMLHttpRequest cannot load http://xingao.5188cms.com/test.php. Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
Step Three
I changed the link to one /test.json
, but I can.
What is the reason for that ....
Access-Control-Allow-Origin
Cross-domain issues
This is the browser limit