Skip to content

Commit

Permalink
fix: use full path in the enrollment failure urls
Browse files Browse the repository at this point in the history
The enrollment failure URLs were using the React Router's
location.pathname, which omits the basename when the MFE is
deployed in a sub-directory. This commit instead uses the
global.location.pathname (browser location api) to make sure
that the full path including the sub-directory is used.
  • Loading branch information
tecoholic committed May 8, 2024
1 parent d78c367 commit 3bfc1ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/course/data/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ export const useCourseEnrollmentUrl = ({
() => ({
next: `${config.LMS_BASE_URL}/courses/${courseRunKey}/course`,
// Redirect back to the same page with a failure query param
failure_url: `${global.location.origin}${location.pathname}?${baseQueryParams.toString()}`,
failure_url: `${global.location.origin}${global.location.pathname}?${baseQueryParams.toString()}`,
}),
[config.LMS_BASE_URL, courseRunKey, baseQueryParams, location.pathname],
[config.LMS_BASE_URL, courseRunKey, baseQueryParams],
);

const enrollmentUrl = useMemo(
Expand Down
2 changes: 1 addition & 1 deletion src/components/course/data/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ export const createEnrollFailureUrl = ({ courseRunKey, location }) => {
baseQueryParams.set(ENROLLMENT_FAILED_QUERY_PARAM, true);
baseQueryParams.set(ENROLLMENT_COURSE_RUN_KEY_QUERY_PARAM, courseRunKey);

return `${global.location.origin}${location.pathname}?${baseQueryParams.toString()}`;
return `${global.location.origin}${global.location.pathname}?${baseQueryParams.toString()}`;
};

export const createEnrollWithLicenseUrl = ({
Expand Down

0 comments on commit 3bfc1ba

Please sign in to comment.