-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make Tutor-MFE config compatible with React Router v6 #574
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit/Note: not all MFEs currently have a
PUBLIC_PATH
configured (e.g., presumably MFEs not officially part of Tutor). That said, things seem to still work as expected in this case asgetConfig().PUBLIC_PATH
falls back to/
if not provided.In the case where
getConfig().PUBLIC_PATH
is/
, thisbasename
function returns an empty string. This would force react-router'sRouter
component'sbasename
prop to fall back to its own/
instead.While it seems to be fine as is, I'm wondering if we should be explicitly handle the fallback to
/
on our own here without relying on the fallback withinRouter
itself? E.g.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do the
/
stripping at all? Based on https://github.com/remix-run/react-router/blob/f9b3dbd9cbf513366c456b33d95227f42f36da63/packages/router/utils.ts#L1031-L1053There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid stripping the tail
/
here, since:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamstankiewicz: I'll make it really explicit in that way, thank you.
@brian-smith-tcril: React Router wants to leave it in our control, but I think that we should be consistent and not have a mix of
/library-authoring/
,/account
,/authn/
, etc. Our backend app config is using the ones without trailing slashes, so the current live URLs don't have trailing slashes. So even though I think that having slashes is actually the right thing to do from an academic perspective, I'd rather be standardized on what's already out there.I do intend to make a separate PR to
tutor-mfe
to fix how it writes this config, but I thought that for rollout/upgrade ease, we should force this behavior across MFEs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arbrandes, @brian-smith-tcril: Okay, I want to make sure I'm not misunderstanding something.
Given the current state of tutor-mfe-generated config and the URLs we currently have, the code is broken without that stripping. Tutor MFE code will generate the PUBLIC_PATH as
/library-authoring/
. Trying to loadhttp://apps.local.overhang.io:3001/library-authoring
(no trailing slash) will cause an error because the route is not specified that way. The only reason this worked (edit: might have worked?) before was because React Router used to be more permissive about what it would accept here, and in v6 they've gotten more explicit.I actually have no objection to removing the stripping behavior and relying on everyone getting the updated tutor-mfe generated config. I was just worried that this would complicate things when people are updating, especially if re-deployment doesn't happen all at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the PR to tutor-mfe to fix the config (overhangio/tutor-mfe#154). I'll remove the slash stripping part from this PR.