Handle Experience Builder and preview environments gracefully#9
Merged
josecdiaz merged 2 commits intosalesforce:mainfrom Apr 27, 2026
Merged
Conversation
Salesforce's own CORS and CSP policies block the Embedded Service bootstrap script and SCRT configuration API from preview domains (*.salesforce-experience.com), making the component non-functional in builder and preview environments. Rather than failing silently or flooding the console with errors, the component now detects these environments on mount and shows a clear informational message: "Chat is not available in the Experience Builder or preview environments. To test this component, publish the site and visit the published URL." Changes: - Add PREVIEW_ERROR_MSG constant and _isPreviewError flag - Guard connectedCallback and handleSubmit against preview domains - Anchor _isSitePreview() to *.salesforce-experience.com subdomains to avoid false positives on customer-owned domains - Hide the "Try again" button for preview errors (retrying won't help) - Update script.onerror fallback to use the same constant and flag - Add Troubleshooting entry to README explaining the behaviour - Set haaSkeletonLoader isExposed to false and remove targets block Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for the contribution! It looks like @dominic-butlerSFDC is an internal user so signing the CLA is not required. However, we need to confirm this. |
Member
Author
|
I have signed the Salesforce CLA |
josecdiaz
requested changes
Apr 24, 2026
Member
josecdiaz
left a comment
There was a problem hiding this comment.
There are still a few minor changes and the PR must be submitted from a Github authoring user.
Moves the Experience Builder/preview error message out of a hardcoded constant and into a new custom label (HAA_error_previewEnvironment) so it can be translated and customised like all other component messages. Bumps version to v1.04. Updates component README to reflect the new label, correct the error variant count, replace the stale "Known Issues" CORS entry with an accurate description of the intentional preview environment handling, and note that "Try again" is hidden for preview errors. Updates the root README Customization section to call out the new label. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
Comments addressed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salesforce's own CORS and CSP policies block the Embedded Service bootstrap script and SCRT configuration API from preview domains (*.salesforce-experience.com), making the component non-functional in builder and preview environments. Rather than failing silently or flooding the console with errors, the component now detects these environments on mount and shows a clear informational message: "Chat is not available in the Experience Builder or preview environments. To test this component, publish the site and visit the published URL."
Changes: