I am facing a weird issue with woocommerce authentication. When I try to authenticate my vue app from URL - /wc-auth/v1/authorize?app_name=example.com
it then redirects to /wc-auth%2Fv1/access_granted/
and gives 404 error.
Notice "%2F" in the URL. If I edit "%2F" to / in the address bar, it works fine. I don't know what I am doing wrong here. I guess woocommerce/wordpress is encoding the url. Any suggestions how to solve this would be very helpful.
I was able to see this issue in several sites that used the WordPress Multilingual (WPML) plugin. Affected sites were running versions > 4.4.6.
The WPML developers are aware of the issue, and they have a ticket which is still open to address it as of this posting (https://wpml.org/errata/endpoints-containing-slashes-are-incorrectly-encoded/).
From that ticket:
Users using WooCommerce extensions or other plugins or themes utilizing endpoints like wc-auth/v1 might see those endpoints incorrectly url-encoded to something like wc-auth%2Fv1.
This can cause compatibility issues with those plugins or themes in the latest versions of WPML.
Our developers are working on a permanent fix for this issue. As a temporary solution, please try the following steps:
Back up your website completely.
Make sure that all of your plugins are up-to-date. Edit the file wp-content/plugins/sitepress-multilingual-cms/classes/url-handling/class-wpml-endpoints-support.php and modify Line 95
From:
return urlencode( $endpoint_translation );
To:
return implode('/', array_map('urlencode', explode('/', $endpoint_translation)));
This change should not affect endpoints that do not contain a slash.