M
M
mr_blond972015-08-25 18:51:17
JavaScript
mr_blond97, 2015-08-25 18:51:17

Why can't I add Access-Control-Allow-Origin headers?

There are two sites, the second one should get the content from the first one using json.

The page of the second site gave an error:

XMLHttpRequest cannot load https:// address of the first site. Request header field Content-Type is not allowed by Access-Control-Allow-Headers.

I finished this header in the virtualhosts of the first site:

Header set Access-Control-Allow-Origin "second site address"

Same error. Added the following header:

Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"

The error message no longer appears in the browser. But the data is still not being pulled. What could be the reason for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
heartdevil, 2015-08-25
@heartdevil

Do you add like this?

header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question