Heyooo!
I’m wondering what the opinions are and possible solutions for doing this. Currently I have a WordPress website hosted at [example.wordpress.com]) and a Next.js client app hosted at [example.client.com]).
Using the REST API, the JSON returned contains WYSIWYG fields and link fields with the WordPress url (ex. [example.wordpress.com/test]) in them however, I need it actually be [example.client.com/test]) so that the routing works correctly in my Next.js app.
Currently, in my Next.js app I run a formatting function on every field that might contain a link and it find and replaces the WordPress URL with my Next.js URLs. That just doesn’t seem like a good solution and the WordPress REST API should return the correct Next.js URLs ideally.
Hope that makes sense. How do you all handle this? Thanks for the help!! 🙏
[ad_2]
Hey there, Is there an issue with your solution? Just trying to understand it better.
>…the WordPress url (ex. example.wordpress.com/test in them however, I need it actually be example.client.com/test so that the routing works correctly in my Next.js app.
It seems you’re missing something in your understanding of REST APIs and routing in JS frameworks as the external REST API URL should have absolutely no bearing on the routing of the app.
The best way would be to return relative urls from the WordPress . Maybe try this plugin : [https://wordpress.org/plugins/make-paths-relative/])
I am working on a similar project as well. Are you also logging the user into your nextJS site ?