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

Question about redirects with headless Wordpress #15

Open
renjogabro opened this issue Nov 20, 2022 · 0 comments
Open

Question about redirects with headless Wordpress #15

renjogabro opened this issue Nov 20, 2022 · 0 comments

Comments

@renjogabro
Copy link

renjogabro commented Nov 20, 2022

Hi Lougie,
Thank you for sharing your work and a live demo! Beatiful work.
I had a somewhat related question, that I was hoping you could help me with or guide me in anyway.

I am trying to build a NextJS frontend with Wordpress and WooCommerce backend, and am opting to do so with the WooCommerce REST api. I noticed that you built this particular repository with WPGraphQl, but that you had an outdated version with REST api.

Thus far I have been following this playlist:
https://www.youtube.com/watch?v=YJj2edx0ZFs&list=PLD8nQCAhR3tSRwsvzRtogv9MFkEWo5d9c&index=10&ab_channel=ImranSayed-CodeytekAcademy

But I ran into a problem. When I update the Wordpress general settings (Wordpress -> Settings -> General) and set the Site Address URL (frontend) to localhost:3000, the permalinks seem to break.
When I try to fetch the WooCommerce data through REST api, I get the error message of 404/500.

It seems that Wordpress automatically redirects my attempts to fetch data from localhost/my-wordpress to localhost:3000/my-wordpress.
I had a similar issue trying to reach localhost/my-wordpress/wp-json (it would add the port of 3000, like so: localhost:3000/my-wordpress/wp-json)

This particular instance I solved by adding index.php, and successfully reach the Wordpress api, like so: http://localhost/nextjs_restapi/index.php/wp-json.

But it didn't work for WooCommerce, and it is not elegant, so I was wondering if you had any ideas about how to solve this problem from happening when changing Wordpress General Settings?

Would really appreciate any suggestions.

Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant