Plugin Contributor
Theo
(@thdespou)
Hello @amrutmhaske. Thank you for the comment.
The Headless Settings Use the WordPress domain for media URLs in post content only works with elements that have a src or a srcset as mentioned in the docs.
The link to the PDF you have on the website is an anchor and so the Enable Post and Category URL rewrites setting will affect the link source. So if you have this setting enabled it will point to the Headless instance:
https://protegrityhdev.wpengine.com/wp-content/uploads/2023/06/Insurance-Case-Study--Aflac--Protegrity.pdf
So since you are using a link to the pdf and you have this setting enabled it will render as:
<a href="https://protegrityhdev.wpengine.com/wp-content/uploads/2023/06/Insurance-Case-Study--Aflac--Protegrity.pdf">Read Now</a>
Disabling this setting will revert this back to:
<a href="https://h6bv7effsscr267x9rjko3w9k.js.wpenginepowered.com/wp-content/uploads/2023/06/Insurance-Case-Study--Aflac--Protegrity.pdf">Read Now</a>
However if Enabling Public Route Redirects is enabled this will redirect back to https://protegrityhdev.wpengine.com and will try to match the next.js route.
In that case there is a filter that you can use to exclude certain routes from being redirected:
https://faustjs.org/reference/faust-wordpress-plugin-filters
Let us know if that solves your issue at hand.
Hello @thdespou
Thank you for your quick response.
As I have checked this issue is not only with the anchor tag but it’s with the src attributes as well, please check the below post featured image URL(https://prnt.sc/cVUmRG1SMneZ).
Page URL: https://h6bv7effsscr267x9rjko3w9k.js.wpenginepowered.com/resource-center/de-identify-your-data
Please check the Headless Settings(https://prnt.sc/pFV-7e_oFhmR)
Thank you
Plugin Contributor
Theo
(@thdespou)
Since you have Enable Post and Category URL rewrites disabled this will keep the existing url and href link to point to the original siteURL() which is your WordPress instance.
Just to not get confused here about the hostnames you are mentioning:
As far as I can understand your WordPress instance is located in:
https://protegrityhdev.wpengine.com/wp-content
And your Headless site is located in:
https://h6bv7effsscr267x9rjko3w9k.js.wpenginepowered.com/
Is that correct?
If that so, are you expecting to get a different src and href links other than the original siteURL when you retrieve content with no replacements?
FYI: you can also reach me in Discord if you want to chat:
https://discord.com/channels/836253505944813629/877940107016019998
My Handle: Theo Despoudis#1014
-
This reply was modified 2 years, 9 months ago by
Theo.
-
This reply was modified 2 years, 9 months ago by
Theo.
-
This reply was modified 2 years, 9 months ago by
Theo.
Hello @thdespou
Thank you for your quick response.
Yes, My WordPress instance is located in:
https://protegrityhdev.wpengine.com/wp-content
And Headless site is located in:
https://h6bv7effsscr267x9rjko3w9k.js.wpenginepowered.com/
We are getting a different src and href links other than the original Headless site Url when retrieving content in the frontend
We want to reflect the media files Url to the Headless site URL is https://h6bv7effsscr267x9rjko3w9k.js.wpenginepowered.com/
for example https://h6bv7effsscr267x9rjko3w9k.js.wpenginepowered.com/wp-content/uploads/2023/06/Insurance-Case-Study–Aflac–Protegrity.pdf
Thank you
Plugin Contributor
Theo
(@thdespou)
Hey amrutmhaske using the Headless site base url for media files will point to 404 since by default those are not valid links:
https://h6bv7effsscr267x9rjko3w9k.js.wpenginepowered.com/wp-content/uploads/2023/06/Insurance-Case-Study–Aflac–Protegrity.pdf
If you want to do something like that you will probably need to write a custom filter for the https://developer.wordpress.org/reference/hooks/the_content/
and instead of replacing the frontend_uri you do the opposite.
Take a look at the example code:
https://github.com/wpengine/faustjs/blob/canary/plugins/faustwp/includes/replacement/callbacks.php#L54-L67
Instead of replacing frontend_uri with siteUrl() you replace siteUrl() with frontend_uri.
-
This reply was modified 2 years, 9 months ago by
Theo.
Hello @thdespou
Thank you for your quick response.
As I have checked and made the page for testing, we have an issue with the media url. The media url loads over the site url, not the frontend url.
Please check the page url: https://h6bv7effsscr267x9rjko3w9k.js.wpenginepowered.com/why-its-critical/drive-growth-2.
I have put the pdf link on the get started button, but it gets a 404 error. Please check that the site URL is opening.
Thank you
Plugin Contributor
Theo
(@thdespou)
Hey @amrutmhaske yes it will throw 404 because it will go through the Next.js file based routes. If you don’t handle the next.js path for that pdf it will respond with 404.
/wp-content/uploads/2023/06/Insurance-Case-Study-<em>-Aflac-</em>-Protegrity.pdf
In that case you want to create a new page that handles the wp-content path in your Headless sites.
You typically want to use custom redirects or middleware here to fetch the associated resource from WordPress.
Not that the getWordPressProps won’t be able to help you here by default since it will try to resolve the seed node for the pdf path which will error as it’s not a valid URI.