Skip to content

Paragon fallbackThemeUrl doesn't handle local development ports properly #802

Closed
@brian-smith-tcril

Description

@brian-smith-tcril

Using frontend-app-authoring as an example. I tried:

What I found:

  • No styles loaded
  • It was trying to load from http://apps.local.openedx.io/authoring/paragon-theme-core.css
    • That file is available at http://apps.local.openedx.io:2001/authoring/paragon-theme-core.css

I did a little digging and got to

export const fallbackThemeUrl = (url) => {
const baseUrl = getConfig().BASE_URL || window.location?.origin;
// validates if the baseurl has the protocol to be interpreted correctly by the browser,
// if is not present add '//' to use Protocol-relative URL
const protocol = /^(https?:)?\/\//.test(baseUrl) ? '' : '//';
return `${protocol}${baseUrl}${basename}${url}`;
};

where getConfig().BASE_URL was apps.local.openedx.io, while window.location?.origin was http://apps.local.openedx.io:2001.

I was able to hack around it with

bsmith@aximdev:~/code/frontend-platform$ git diff
diff --git a/src/react/hooks/paragon/utils.js b/src/react/hooks/paragon/utils.js
index 6b05deb..196b85d 100644
--- a/src/react/hooks/paragon/utils.js
+++ b/src/react/hooks/paragon/utils.js
@@ -17,7 +17,7 @@ export const removeExistingLinks = (existingLinks) => {
 * @returns {string} The default theme url.
 */
 export const fallbackThemeUrl = (url) => {
-  const baseUrl = getConfig().BASE_URL || window.location?.origin;
+  const baseUrl = (getConfig().BASE_URL && getConfig().ENVIRONMENT !== "development") || window.location?.origin;
 
   // validates if the baseurl has the protocol to be interpreted correctly by the browser,
   // if is not present add '//' to use Protocol-relative URL

but it'd be good to come up with a proper solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions