-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Basename is not used in createHref #3839
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
Comments
Pass it in as a prop to BrowserRouter or HashRouter. |
I'm doing that, but it seems to be ignored for the |
I'll double-check when I'm at a computer, but it's got tests at least: http://github.com/ReactTraining/react-history/commit/b61ae2c362a34fe6545b24f5f06c77d23ab050b7 |
I do about this: <Router basename='/foo'>
<Match exactly pattern="/" render={()=><Link to="/">Index</Link>} />
</Router> The link renders as |
My comments in #3843: #3843 (comment) Those tests didn't cover Link's href. |
Ah, shazbot. Well, that's a little confusing as to who should be responsible then? Let me see what the thought process is on that and we can either re-open that PR or integrate the ideas in a more clear API. I feel like history should be aware of it, but we'll see if that stops at react-history or not. Either way, thanks for this issue! |
Link
href
Just to clarify where responsibilities are: history has no knowledge of queries, so router is responsible for creating hrefs. It does know about basenames, but all EDIT: Likewise, all paths that you pass to functions like |
Now I'm confused. Consider the following: <Router basename='/foo'>
...
<Link to={"bar"} /> // renders `href='/foo/bar'` but transitions to `/foobar` [sic]
<Link to={"/bar"} /> // renders `href='/bar'` but transitions to `/foo/bar`
...
</Router> I'd say they should both behave the same, i.e. render |
@jochenberger That is not how it should end up behaving. This area of the code should be considered "in progress". |
Yes, I thought so, that's why I let you know. ;-) |
I'm looking into this today. |
Is there any progress on this? I've noticed that the behavior for this in the
That last comment is the issue. If my application exists at |
@nibblesnbits If your app exists at Basenames are used to change the root url (location of |
Hey @pshrmn, basename is required for that /calendar thing because it is a subdirectory and not the actual root of the webserver. |
07725d7 fixes this? let me know if it doesn't and we'll reopen. |
Hello @ryanflorence, sorry for a stupid question but how can I try this thing out? Is it already merged and published on npm? I found that this was merged a month ago but I experienced these issues a few days ago so in that case this commit wasnt helpful. Thanks in advance. |
@patotoma, the easiest way I know of is to
|
I use a
basename
in my router setup. In one of my components I have aLink to="/"
. Thehref
attribute points tohttp://${hostname}/
instead ofhttp://${hostname}/${contextPath}
. The click handler works fine though.The text was updated successfully, but these errors were encountered: