CalebBarnes / nextwp

http://nextwp.org/
7 stars 0 forks source link

add support for WP install with Site Address (URL) in WP Settings differing from the WP admin / rest api endpoint url #26

Open CalebBarnes opened 7 months ago

CalebBarnes commented 7 months ago

In WP, it is possible to set the site address as the headless frontend url! This updates all of the site links to use the actual Next.js frontend url instead of the cms links.

Image

This would be super nice being able to click "View post" and it would open the frontend instead of the backend page.

But this also changes the post links in the WP REST API.

So far in our sitemap generation, we have just been using an ENV NEXT_SITE_URL and just swapping out the NEXT_PUBLIC_WP_URL with this NEXT_SITE_URL one. If the correct frontend url is added in WP we could just use the real site url.

To implement this, we would need to explore all of the possible side effects, like what happens when linking directly to a media asset like an mp4 video, etc.

We would also need to make sure getPageData is resolving these url paths correctly. Right now when we are resolving the page routes as relative paths we are just stripping out the NEXT_PUBLIC_WP_URL from the page link.