Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP JSON API URLs don't work on sub-directory multisite #39

Open
kasparsd opened this issue Sep 13, 2024 · 1 comment
Open

WP JSON API URLs don't work on sub-directory multisite #39

kasparsd opened this issue Sep 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kasparsd
Copy link

Describe the bug
When attempting to use the plugin on a subdomain multisite site such as example.com/site-one, the REST API URLs in all JS files point to the root site example.com/wp-json/... instead of example.com/site-one/wp-json/....

To Reproduce
Steps to reproduce the behavior:

  1. Go to plugin settings page.
  2. Click on "Connect to Lemon Squeezy"
  3. Accept the connection and get redirected back to the site.
  4. Notice that the site is still not connected -- the same "Connect to" button is shown.

Expected behavior
Site can be connected to Lemon Squeeze when used from WP sub-directory multisite.

Screenshots

Software (please complete the following information):

  • Plugin version: 1.3.0
  • WordPress version: 6.6.2
  • PHP version: 7.4
  • Browser: Safari and Chrome

Additional context

@kasparsd kasparsd added the bug Something isn't working label Sep 13, 2024
@kasparsd
Copy link
Author

The issue is caused by the hardcoded REST API paths in all JS files such as:

return fetch("/wp-json/lsq/v1/validate")

Using the @wordpress/api-fetch library for sending the REST API requests automatically takes care of using the correct site URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant