Skip to content

fix _root.data fetch when basename is set, closes #12295 #12898

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

Merged
merged 6 commits into from
Feb 19, 2025

Conversation

Aleuck
Copy link
Contributor

@Aleuck Aleuck commented Jan 29, 2025

This should fix #12295

Copy link

changeset-bot bot commented Jan 29, 2025

🦋 Changeset detected

Latest commit: d7f7e91

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Aleuck Aleuck force-pushed the fix-basename-data-fetch branch from 9da65df to 304ca2c Compare January 29, 2025 19:43
@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 29, 2025

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@Aleuck Aleuck force-pushed the fix-basename-data-fetch branch from 304ca2c to 2756c5a Compare January 29, 2025 19:51
@timdorr
Copy link
Member

timdorr commented Jan 29, 2025

Can you add a test of some sort so we can prevent a regression?

@Aleuck Aleuck changed the base branch from main to dev January 30, 2025 02:37
@Aleuck Aleuck force-pushed the fix-basename-data-fetch branch from 2756c5a to d745985 Compare January 30, 2025 02:38
@Aleuck
Copy link
Contributor Author

Aleuck commented Jan 30, 2025

Can you add a test of some sort so we can prevent a regression?

Added a couple of tests, @timdorr.
I changed the base to dev, not sure if it is the most appropriate.

@Aleuck Aleuck force-pushed the fix-basename-data-fetch branch 2 times, most recently from 9f42f4c to ec2ac31 Compare January 30, 2025 03:04
@Aleuck
Copy link
Contributor Author

Aleuck commented Jan 30, 2025

I am not quite sure if it is possible access the basename when singleFetchUrl is being called in a SSR context. This might not be a complete fix.

The integration tests failed because I forgot to test the availability of window. I just fixed that.

@s-cochrane
Copy link

@timdorr, any updates here? We've applied @Aleuck's patch in the meantime with good success, but we would love to see this fix merged upstream. This is going to be a big issue for anyone running a full-stack RR app behind a reverse proxy and not on the base path of the domain. Our use-case is we're using a new RR app to replace an aging legacy app via the strangler-fig pattern.

@timdorr timdorr requested a review from brophdawg11 February 12, 2025 17:56
@timdorr
Copy link
Member

timdorr commented Feb 12, 2025

I made a request to @brophdawg11 to get a review. Hopefully we can land this for 7.2.0. 🤞

@Aleuck Aleuck force-pushed the fix-basename-data-fetch branch from 9eb6262 to 61daf31 Compare February 15, 2025 19:08
@Aleuck
Copy link
Contributor Author

Aleuck commented Feb 16, 2025

I would like to find a way to introduce tests for the createRequestHandler, and also integration tests. But the mocks and fixtures generators are not ready to handle basename and it does not seem to be too simple to make it work.

@brophdawg11 brophdawg11 self-assigned this Feb 18, 2025
@brophdawg11
Copy link
Contributor

Ugh, sorry I missed this mention. Between paternity leave late last year and then the holiday break my github notifications are still a mess so I'm not catching these types of mentions. @brookslybrand just called my attention to this and it won't make it into 7.2 but I will look at it right after and we can get into dev for the next release.

Copy link
Contributor

github-actions bot commented Mar 6, 2025

🤖 Hello there,

We just published version 7.3.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@skrhlm
Copy link

skrhlm commented Mar 7, 2025

howdy! great stuff addressing this, however if i understand correctly this only applies to the case when you're running this using ssr? this fix would not work on a fully prerendered site, being deployed statically?

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: RR7 - With basename configured, .data requests against root index not correctly routed
5 participants