ramesh kumar
ramesh kumar

Reputation: 1707

Access-Control-Allow-Origin Error : i tried setting headers to allow domains but still not working,

i tried like this :

<head>
<meta http-equiv="Access-Control-Allow-Origin" content="http://localhost" />
<script src="jquery.js" type="text/javascript" ></script>
</head>

i tried putting * also, i tried running directly by opening an html file on the computer and also i tried using http://localhost/filename.php , tried /filename.html , but didnt work .

Tried below php code also(i put that above html tag) :

<?php
header('Access-Control-Allow-Origin : *');
?>
<html>
<head>

But getting error : Origin http://localhost is not allowed by Access-Control-Allow-Origin.

If i run directly from file, getting error : Origin null is not allowed by Access-Control-Allow-Origin.

Whats the solution ?
Thanks

Upvotes: 2

Views: 1736

Answers (1)

Dave
Dave

Reputation: 1450

This is a server setting (as far as I understand it). You can put this in an Apache (if you're running Apache) config file in the <Directory>, <Location>, <Files> or <VirtualHost> sections, or within an .htaccess file:

Header set Access-Control-Allow-Origin *

Also, * could be "http://localhost". Make sure mod_headers is enabled/installed.

Upvotes: 1

Related Questions