Support for Envato Buyers › Forums › Mostore › Prevent CORB from Localhost?
- This topic has 10 replies, 2 voices, and was last updated 5 years ago by
FocuxTheme Support.
-
AuthorPosts
-
-
February 8, 2020 at 11:21 pm #28076
latusapp
ParticipantHi, 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
-
February 12, 2020 at 7:03 pm #28104
FocuxTheme Support
KeymasterHi
You can give this extension a test for local development environment
https://chrome.google.com/webstore/detail/moesif-orign-cors-changer/digfbfaphojjndkpccljibejjbppifbc/related?hl=enThanks
-
February 12, 2020 at 11:38 pm #28107
latusapp
ParticipantI 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? -
February 13, 2020 at 4:54 pm #28116
FocuxTheme Support
KeymasterNo 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
-
February 16, 2020 at 8:55 pm #28132
latusapp
ParticipantUnfortunately 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 -
February 16, 2020 at 8:57 pm #28133
latusapp
ParticipantI 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.
-
February 16, 2020 at 8:59 pm #28135
latusapp
ParticipantHere is the console when the issue happens
https://drive.google.com/file/d/1pW_xvlbl6BdqCdlMe3MieUHyCph9g4-O/view?usp=sharing -
February 20, 2020 at 9:38 pm #28158
FocuxTheme Support
KeymasterIt’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?
-
February 21, 2020 at 12:49 am #28160
latusapp
ParticipantMy 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 -
February 22, 2020 at 9:59 pm #28175
FocuxTheme Support
KeymasterHave 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
-
-
AuthorPosts
- You must be logged in to reply to this topic.