Support for Envato Buyers Forums Mostore Prevent CORB from Localhost?

Viewing 9 reply threads
  • Author
    Posts
    • #28076
      latusapp
      Participant

      Hi, I am developing on the PWA from the source code,

      I am trying to login to the PWA, and I can see through the network requests that all of the traffic from Localhost is being blocked by CORB. I think this is the reason I can’t login through my development build on Localhost.

      How can I allow origin from Localhost? Can I allow origin through the API PHP files?

      Here is a screenshot from my development build, (localhost) https://drive.google.com/file/d/1_4E-yNt3W0ONj7I9CY52QFvDM0_QIUld/view?usp=sharing

    • #28104

      Hi

      You can give this extension a test for local development environment
      https://chrome.google.com/webstore/detail/moesif-orign-cors-changer/digfbfaphojjndkpccljibejjbppifbc/related?hl=en

      Thanks

    • #28107
      latusapp
      Participant

      I tried the extension but it didn’t make a difference unfortunetly,
      I can see that my /wp-json/wp/v2/mofect/login API call is being preflighted (With an Options request) whenever i’m using Localhost. I think that is the reason why I can’t login from Localhost, have you ever seen this behavior? Do you have any more development build instructions?

    • #28116

      No special instruction, sometimes, it’s the server-side issue, but I’m not sure.
      You can give a test:

      Edit the Mofect Mobile plugin file ( inc/api/wp_login.php ), find “return $respond;”, change to

      header('Access-Control-Allow-Origin: *');
      header('Content-Type: application/json');
      return $respond;
      

      Please let me know the result.

      Thanks

    • #28132
      latusapp
      Participant

      Unfortunately that did not work.
      Could this be an issue with the Router? Because I see that the action ‘WP_LOGGED_IN’ is being called after succesfully logging in, but I am never redirected to the account page, despite the showPage function being called.

      Here is a screenshot of where I added the snippet
      https://drive.google.com/open?id=15nXO_rC5n4-iFdsJfXbMbzLOCnhjSFfg

    • #28133
      latusapp
      Participant

      I am still seeing a preflight with the Options request, then the user is logged in to the state. But i’m never redirected away from the Login credentials page.

    • #28135
      latusapp
      Participant
    • #28158

      It’s hard to know what’s wrong with your local development environment and how is the configuration of your web hosting, because I can’t reproduce this issue on my localhost.

      You can give a test once again, add the following codes to functions.php of your theme.

      function add_cors_http_header(){
      header("Access-Control-Allow-Origin: *");
      header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS, READ');
      header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token,authorization,XMLHttpRequest, user-agent, accept');
      header("Access-Control-Allow-Credentials: true");
      
      if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
          status_header(200);
          exit();
      }

      If still doesn’t work, just change

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

      to

      header("Access-Control-Allow-Origin: http://localhost:8100");

      Remember replace the port of http://localhost:8100 to yours.

      By the way, is your wordpress installed on the web hosting or also on the local environment? What’s the version of Mostore you use?

    • #28160
      latusapp
      Participant

      My wordpress is installed on web hosting (Bluehost)
      Do i need to install it locally to develop locally? Everything else works beside the login.
      I am using version 1.0.6

    • #28175

      Have you tried the method I mentioned above? Add the following codes to functions.php of your theme

      function add_cors_http_header(){
      header("Access-Control-Allow-Origin: *");
      header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS, READ');
      header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token,authorization,XMLHttpRequest, user-agent, accept');
      header("Access-Control-Allow-Credentials: true");
      if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
          status_header(200);
          exit();
      }
      

      Also, the latest version of App is v1.1.2, so if possible, you can download it to use.

      You don’t need to install WordPress on localhost. In most cases, this kind of issue is the server-side configuration, but I’m not sure the bluehost web hosting configuration, because I use VPS. Anyway, you can try the method above.

      Of course, if possible, you can install a wordpress on your localhost with local SSL, then connect it to App, check if the login feature is working or not.

      Thanks

Viewing 9 reply threads
  • You must be logged in to reply to this topic.