Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Cross-Origin Request Blocked on wordpress

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1.57k
    Comment on it

    Cross domain request is a HTTP request from other domain. Browsers do not support the XmlHttpRequest from other domain. Cross origin resource sharing provides a way to allow these type of requests. You need to set the headers to allow the other domain in your file. It supports both request methods such as GET and POST and provides the error handling as well that's why it is more beneficial than the jsonp request which supports only GET request method.

    We can allow the other third party server to access the files from your website setup. If you are looking fro this then you need to write the following in your file

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

    OR

    You need to set the following code in your .htaccess file

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    <FilesMatch "\.(php)$">
      <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
      </IfModule>
    </FilesMatch>
    
    # END WordPress 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: