jbambrough
jbambrough

Reputation: 633

How do I change the react router path from /#/homepage to /app/#/homepage

We are using Node.js server and React Router. We have SSO rules that will require us to change our URL pattern. I am trying to adjust the default paths from this pattern:

mysite.com/#/homepage

to:

mysite.com/app/#/homepage

I believe by default the hash is handled directly after the domain, but as you can see we are trying to prepend it with 'app' instead. How can this be done? We are currently using React Router like so:

<Route name="app" path="/" handler={App}>
  <Redirect from="/" to="homepage" />
  <Route path="homepage" name="home" handler={MyContent} />
</Route>

Upvotes: 0

Views: 1734

Answers (2)

Fakhruddin Abdi
Fakhruddin Abdi

Reputation: 906

With a hash approach you CAN NOT. It's like you want to do something like this :

mysite.com/homepage -> mysite.net/homepage

Because client can just see the part of URL next to #.

So you may consider handling your routes using server-side approach.

It give you more power and flexiblity than the # approach.

Upvotes: 0

Connorelsea
Connorelsea

Reputation: 2458

Host your app itself/serve your app on /app. Either via some kind of DNS, etc. depending on your server structure.

Upvotes: 1

Related Questions