Skip to content

Commit

Permalink
fix: remove slash trimming and rely on proper tutor-mfe config
Browse files Browse the repository at this point in the history
  • Loading branch information
ormsbee committed Oct 3, 2023
1 parent 6f080b2 commit 5d57eec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions src/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import {
APP_READY, APP_INIT_ERROR,
} from './constants';
import configureCache from './auth/LocalForageCache';
import { config } from 'localforage';

Check failure on line 92 in src/initialize.js

View workflow job for this annotation

GitHub Actions / tests

`localforage` import should occur before import of `./utils`

Check failure on line 92 in src/initialize.js

View workflow job for this annotation

GitHub Actions / tests

'config' is defined but never used

/**
* A browser history or memory history object created by the [history](https://github.com/ReactTraining/history)
Expand All @@ -105,22 +106,14 @@ export const history = (typeof window !== 'undefined')
/**
* The string basename that is the root directory of this MFE.
*
* In devstack, this should always just return an empty string, because each MFE is in its own
* server/domain.
* In devstack, this should always just return "/", because each MFE is in its own server/domain.
*
* In Tutor, all MFEs are deployed to a common server, each under a different top-level directory.
* The basename is the root path for a given MFE, e.g. "/library-authoring". It is set by tutor-mfe
* as an ENV variable in the Docker file, and we read it here from that configuration so that it
* can be passed into a Router later.
*
* By convention, our basenames do not have a trailing slash. So it's "/library-authoring", and not
* "/library-authoring/". Our configuration is inconsistent on this, so this function always strips
* off the trailing slash from any value entered in configuration.
*/
export function basename() {
const configBasename = getPath(getConfig().PUBLIC_PATH);
return configBasename.endsWith('/') ? configBasename.slice(0, -1) : configBasename;
}
export const basename = getPath(getConfig().PUBLIC_PATH);

/**
* The default handler for the initialization lifecycle's `initError` phase. Logs the error to the
Expand Down
2 changes: 1 addition & 1 deletion src/react/AppProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function AppProvider({ store, children, wrapWithRouter }) {
>
<OptionalReduxProvider store={store}>
{wrapWithRouter ? (
<Router basename={basename()}>
<Router basename={basename}>
{children}
</Router>
) : children}
Expand Down

0 comments on commit 5d57eec

Please sign in to comment.