JavaScript URLs are not updating when Staging is enabled
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- With staging enabled, JavaScript URLs, referencing content in Documents and Media, are not updating when a page is published from Staging to Live
- For example:
- JS URL on Staging:
src:'http://localhost:8080/documents/d/guest-staging/astronaut-png'
- JS URL on Live:
src:'http://localhost:8080/documents/d/guest/astronaut-png'
- Note change from "guest-staging" to "guest"
- This behavior was working previously in Liferay 7.0
Resolution
- This is the expected behavior of the product as of 2024.Q2 Quarterly Release.
- We are unable to modify the URLs from Staging to Live within a JavaScript script. This is due to the vast array of potential use cases and the complexity of how these URLs are integrated into different JavaScript environments
- The URL was working previously in Liferay 7.0, but was susceptible to different user errors. The behavior changed as subsequent versions of Liferay were released to address different issues
- A work-around would be to publish content to the Live site separately from the page, and then paste the Live URL into your JavaScript src field
Did this article resolve your issue ?