Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Widget connections fail when REACT_APP_WIDGETS_URL ends with a trailing slash, causing double-slash artifacts in constructed URLs (https://example.com//path).

Changes

  • Added removeTrailingSlash() utility to strip trailing slashes from URL strings
  • Applied to REACT_APP_WIDGETS_URL, REACT_APP_DAPP_VIEW_MODE, and REACT_APP_DR_CENTER_VIEW_MODE at config load time

Implementation

export function removeTrailingSlash(url: string | undefined): string {
  if (!url) return "";
  return url.endsWith("/") ? url.slice(0, -1) : url;
}

const widgetsUrl = removeTrailingSlash(process.env.REACT_APP_WIDGETS_URL);

Normalizes https://widgets.bosonprotocol.io/https://widgets.bosonprotocol.io before use in iframe src construction and origin checks.

Original prompt

This section details on the original issue you should resolve

<issue_title>Env variables that link to website URL should not end with "/". Ensure the "/" is removed in the code, if any.</issue_title>
<issue_description>when setting
REACT_APP_WIDGETS_URL=https://widgets.bosonprotocol.io/
instead of
REACT_APP_WIDGETS_URL=https://widgets.bosonprotocol.io
the connection with widget is not working well.

Make the necessary changes in the code so that the "/" is removed at the end of the variable value, in case it exists
This has to be done with the following env vars:

  • REACT_APP_WIDGETS_URL
  • REACT_APP_DAPP_VIEW_MODE
  • REACT_APP_DR_CENTER_VIEW_MODE

This could be done in the file 'src\lib\config.ts', when the env var values are read and copied into the CONFIG object
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

…nment variable URLs

Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix env variables to remove trailing slash from website URLs Remove trailing slashes from URL environment variables Nov 11, 2025
Copilot AI requested a review from levalleux-ludo November 11, 2025 11:12
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 11, 2025

Deploying interface with  Cloudflare Pages  Cloudflare Pages

Latest commit: bda5713
Status: ✅  Deploy successful!
Preview URL: https://85209066.interface-a9d.pages.dev
Branch Preview URL: https://copilot-fix-env-vars-url-end.interface-a9d.pages.dev

View logs

@levalleux-ludo levalleux-ludo changed the title Remove trailing slashes from URL environment variables chore: remove trailing slashes from URL environment variables Nov 11, 2025
@levalleux-ludo levalleux-ludo marked this pull request as ready for review November 11, 2025 16:07
@levalleux-ludo levalleux-ludo requested a review from a team as a code owner November 11, 2025 16:07
@levalleux-ludo levalleux-ludo merged commit 71b5f7a into main Nov 11, 2025
14 of 20 checks passed
@levalleux-ludo levalleux-ludo deleted the copilot/fix-env-vars-url-ending-slash branch November 11, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Env variables that link to website URL should not end with "/". Ensure the "/" is removed in the code, if any.

3 participants