• I am getting my authorization token just fine in postman but the second i try and receive my token via my mobile application. I recieve the following error.

    XMLHttpRequest cannot load https://hisword365.com/oauth/token. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://localhost:8100’ is therefore not allowed access.

    I have done what is laid out in this article, but the issue is still not fixed.

    I also tried to post this ticket via the support system on the website but things seem to be broken.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Justin Greer

    (@justingreerbbi)

    Could you please try to open a new ticket again? Our server has been migrated back to the original server and all issues should be resolved.

    Thread Starter meatloaf1024

    (@meatloaf1024)

    I will go ahead and try and do that.

    Thanks in advance!

    Thread Starter meatloaf1024

    (@meatloaf1024)

    I tried to submit the ticket and unfortunately it still isn’t working.

    After submitting I get redirected to a blank screen. I see the ticket as open in my support page but every time I click it it ends up just refreshing the page.

    Plugin Author Justin Greer

    (@justingreerbbi)

    I am seeing issues still while the DNS propagates. Where have you tried to place the snippet that is in the article?

    • This reply was modified 8 years, 4 months ago by Justin Greer.
    Thread Starter meatloaf1024

    (@meatloaf1024)

    In the function.php file of my theme

    Not sure if this helps but here is my Angular 2 code that I am using to send the http post request

      constructor(public http: Http) {
        this.headers = new Headers();
        this.headers.append('Content-Type','application/x-www-form-urlencoded');
        //this.headers.append('')
        this.headers.append('Authorization', "Basic " + btoa(this.clientId + ":" + this.clientSecret));
      }
    
      //queries the database for an auth token so that we can log in to the application
      public signIn(usrnme: string, psswrd: string) : Observable<any>{
    
        let body = this.jsonToURLEncoded({ grant_type: "password", username: usrnme, password: psswrd });
        console.log(body);
        let options = new RequestOptions({ headers: this.headers });
        let signOnUrl = this.websiteUrl + this.signInUrl;
    
        return this.http.post(signOnUrl, body, options)
          .map( this.simplifySignIn )
          .catch( this.simplifySignInError );
    
      }
    • This reply was modified 8 years, 4 months ago by meatloaf1024.
    Plugin Author Justin Greer

    (@justingreerbbi)

    Please try to place

    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>

    in your .htaccess file and try again.

    Thread Starter meatloaf1024

    (@meatloaf1024)

    Ok great i’ll go ahead and give that a try. It might take me a minute while I get access to the server to modify that file.

    Thread Starter meatloaf1024

    (@meatloaf1024)

    By the way. The .htaccess file code is in addition to the code pasted into the function.php file correct?

    Thread Starter meatloaf1024

    (@meatloaf1024)

    I managed to get it all working by adding that bit of code to my htaccess as well as removing the below line from the function instructed to create in the functions.php file.

    header('Access-Control-Allow-Origin: *');

    I am curious though isn’t this sort of countering what the function was trying to stop?

    Thanks in advance!

    Thread Starter meatloaf1024

    (@meatloaf1024)

    Just wanted to double check if you saw my last two messages. As it stands currently I have the function along with the line you told me to add in the htaccess file.

    Plugin Author Justin Greer

    (@justingreerbbi)

    Hi and sorry for the delayed responses. I have been having some server issues that needed to be address ASAP.

    The idea of the function in the functions.php file is to have PHP handle the header for the server. This should of worked and I am going to be looking into why it was not. These type of things are hard to track down due to the magnitude of different server stacks and configurations.

    The .htaccess method is to have the server handle the origin access issue without the help of PHP.

    You should only need one of solutions and not both. You have this working now? I just want to be clear to ensure I have the whole story.

    Thanks

    Thread Starter meatloaf1024

    (@meatloaf1024)

    No worries on the late reply.

    Everything seems to be working correctly now. For anyone else having the same problem this is my final code.

    in my .htaccess I appended

    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>

    And in my functions.php I have

    //Used for mobile application login
    function wo_cors_check_and_response(){
    if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
        header('Access-Control-Allow-Methods: POST, GET');
        header('Access-Control-Allow-Headers: Authorization');
        header('Access-Control-Max-Age: 1');  //1728000
        header("Content-Length: 0");
        header("Content-Type: text/plain charset=UTF-8");
        exit(0);
      }
    }
    add_action('wo_before_api', 'wo_cors_check_and_response');
    Plugin Author Justin Greer

    (@justingreerbbi)

    Thanks for the solution. I am sure others will find this very useful.

    Hi,

    I get the semae error on my website : https://www.exanergy.fr/fr/contact/

    I have a redirection on valid : on_sent_ok: “location = ‘//exanergy.fr/fr/merci-exanergy-crm/’;”

    But when I delete it the error is still there.
    I’ve try your solutions but it’s not woring for me.

    Have you an idea ?

    Diane

    Thanks a ton for the solution meatloaf. Was having trouble loading up lightbox images on mobile – Ran my website in Google Developer tools and it came back with roughly same error message. Found this post and uploaded this into my wordpress and works like a charm ?? Shared it with some others on another forum. Thanks again!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘No ‘Access-Control-Allow-Origin’ header is present on the requested resource’ is closed to new replies.