-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Support <base href> in HTML documents #2014
Comments
I am also unsure why the |
And maybe it can be a good idea to add a |
Relevant: we now have support for basenames in the history package. |
splat
param
Good to know :) |
So, for now I think you can just do this: import { createHistory, useBasename } from 'history'
const history = useBasename(createHistory)({
basename: document.getElementsByTagName('base')[0].getAttribute('href')
})
React.render((
<Router history={history}>
// ...
</Router>
), node) I do still think that we could try to do this automatically, but why don't you try it for now and let me know how it goes :) |
BTW, you'll need rc1 to do this. rc2 should be ready this week. |
Since this seems like more of history issue, let's follow up in remix-run/history#94. |
Reminder https://developer.mozilla.org/en/docs/Web/HTML/Element/base
my route(s):
I am currently using react-router (beta 3) with a
<base href="/mybase/" />
and I am getting issue with thesplat
params depending on how I load a page:/mybase/
, my splat is "mybase"<Link to="docs/setup">Setup</Link>
, I go correctly to/mybase/docs/setup
(which is correct according to how<base>
should help me) and mysplat
isdocs/setup
- this is good for me<Link to=".">Home</Link>
, I got assplat
the value.
. A bit weird, but it's ok too, since according to my base url, give me the right full url when doing my xhr request (I use xhr to load my data)My main issue here is the behavior of the first time, which is reproducible by navigating to the home by bypassing the
<base >
with something like this<Link to="/mybase/">Home</Link>
.According to the
<base>
doc,<Link to="/mybase/">Home</Link>
is equal to<Link to=".">Home</Link>
if base is set to/mybase/
.But in the context of react-router, the
splat
(and so probably all the routing) can be confused.A detail that frustrate me is that
splat
does not keep the slashes around the value. If I got splat to.
or/mybase/
(instead of.
andmybase/
-- without slashes) I could get my code working "as expected".I will try to upgrade to 1.0 (not beta), but I didn't find any reference to the
<base>
...Or maybe there is just a wait to get slashes in the
splat
value ?The text was updated successfully, but these errors were encountered: