Paka Information

No Access-Control-Allow-Origin header

797 0

No Access-Control-Allow-Origin header

Today, We want to share with you No Access-Control-Allow-Origin header.
In this post we will show you How to solve – No ‘Access-Control-Allow-Origin’, hear for How to fix Access-Control-Allow-Origin (CORS origin) we will give you demo and example for implement.
In this post, we will learn about ERROR : No “Access-Control-Allow-Origin” header is present with an example.

Error: “No Access-Control-Allow-Origin header” is some data present on the data requested main resource.

How to solve – No ‘Access-Control-Allow-Origin’ – Syntax

The simple used in server side Access-Control-Allow-Origin some response Data header indicates some results whether the data response can be more shared with data resources with the given PHP, .net, webapi, C#, etc. origin.

Also Read :  Creating Dynamic XML Sitemaps Generator Using PHP MySQLi

Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: <origin>

PHP SET- Access-Control-Allow-Origin

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

If you are using Latest , For used to:

app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});

For c# web services – webapi

Please put the following source code in your App web.config simple file under C# tag tag.

<httpProtocol>
    <studentHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
    </studentHeaders>
</httpProtocol>

Please create sure you are not any access doing any some mistake in the jquery ajax call

jQuery

$.ajax({
    url: 'http://live24u.com/api/mycall',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    }, 
    type: "POST", /* methods or type:"GET" methods or type:"PUT" methods */
    dataType: "json", //dataType
    data: {
    },
    success: function (data) {
        console.log(data);    
    },
    error: function () {
        console.log("error");
    }
});

Mixed Content: The page was not data loaded over HTTPS. This some request has been blocked.

Also Read :  Top 10 Advanced AngularJS Interview Questions Answers

In some order to fix an issue for your WordPress website or ay blog, just put simple below source code into your root .htaccess file.

.htaccess

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

As you Display Access-Control-Allow-Origin “*” some allows you to all the file access all folder and files resources and webfonts from all this domains.

We hope you get an idea about No ‘Access-Control-Allow-Origin’ solve this error header is present
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

Also Read :  Get Fully Google Adsense Approval Fast Trick and Tips

We hope This Post can help you…….Good Luck!.

Leave A Reply

Your email address will not be published.